Please help analyzing arithmetic formatter output

Here is the link to my repl: boilerplate-arithmetic-formatter - Replit

It passes all the error tests and the output looks identical to the requirements, but fails 4 tests. I took the lists from the test file and ran them from the module the output looks correct. Maybe there is something I cannot see. Any advice is greatly appreciated

The errors will give you a lot of information, looking at the first one:

________________ test_template[test_two_problems_arrangement1] _________________

arguments = [['3801 - 2', '123 + 49']]
expected_output = '  3801      123\n-    2    +  49\n------    -----'
fail_message = 'Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]'

>   ???
E   AssertionError: Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]
E   assert '  3801      123\n-    2    +  49\n------    -----\n  3799      172' == '  3801      123\n-    2    +  49\n------    -----'
E         3801      123
E       -    2    +  49
E     - ------    -----
E     + ------    -----
E     ?                +
E     +   3799      172

I find the assert very useful:

assert ’ 3801 123\n- 2 + 49\n------ -----\n 3799 172’ == ’ 3801 123\n- 2 + 49\n------ -----’

Looking at it in fixed width:

'  3801      123\n-    2    +  49\n------    -----\n  3799      172'
'  3801      123\n-    2    +  49\n------    -----'

First is your output, then the expected output. You can easily see the difference this way.

This part shows you the same information in a different way:

E         3801      123
E       -    2    +  49
E     - ------    -----
E     + ------    -----
E     ?                +
E     +   3799      172

A line that starts with - is your incorrect line
A line with + is correct
the ? line shows the difference, the + there indicates that there is an extra space.

I hope this helps?

2 Likes

It was confusing at first but I got it! Thank you very much for your time

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.