Scientific Computing with Python Projects - Arithmetic Formatter

Tell us what’s happening:
not sure what the test output is saying and need some help understanding it

__________________ 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"]'

    @pytest.mark.parametrize('arguments,expected_output,fail_message', test_cases)
    def test_template(arguments, expected_output, fail_message):
        actual = arithmetic_arranger(*arguments)
>       assert actual == expected_output, fail_message
E       AssertionError: Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]
E       assert None == '  3801      123\n-    2    +  49\n------    -----'
E         +None
E         -'  3801      123\n-    2    +  49\n------    -----'

test_module.py:77: AssertionError
------------------------------- Captured stdout call -------------------------------
  3801      123
-    2    +  49
------    -----
    

Your code so far
link to replit code: boilerplate-arithmetic-formatter - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge: Scientific Computing with Python Projects - Arithmetic Formatter

Link to the challenge:

when i set it to return instead of print i get

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' == '  3801      123\n-    2    +  49\n------    -----'
E     -   3801      123
E     ?                -
E     +   3801      123
E     - -    2    +  49
E     - ------    -----

/home/runner/boilerplate-arithmetic-formatter-1/test_module.py:77: AssertionError

after remembering to have only one return i get

__________________ 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    ' == '  3801      123\n-    2    +  49\n------    -----'
E         3801      123
E       -    2    +  49
E     - ------    -----
E     + ------    -----
E     ?                +
E     +

/home/runner/boilerplate-arithmetic-formatter-1/test_module.py:77: AssertionError

i solved all but the two tests with results and i think now i just need to right adjust the solution number

last error i have to solve is

_________________ test_template[test_five_problems_with_solutions] _________________

arguments = [['32 - 698', '1 - 3801', '45 + 43', '123 + 49', '988 + 40'], True]
expected_output = '   32         1      45      123      988\n- 698    - 3801    + 43    +  49    +  40\n-----    ------    ----    -----    -----\n -666     -3800      88      172     1028'
fail_message = 'Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with five arithmetic problems and a second argument of `True`.'

>   ???
E   AssertionError: Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with five arithmetic problems and a second argument of `True`.
E   assert ('   32         1      45      123      988\n'\n '- 698    - 3801    + 43    +  49    +  40\n'\n '-----    ------    ----    -----    -----\n'\n '                                         ') == ('   32         1      45      123      988\n'\n '- 698    - 3801    + 43    +  49    +  40\n'\n '-----    ------    ----    -----    -----\n'\n ' -666     -3800      88      172     1028')
E          32         1      45      123      988
E       - 698    - 3801    + 43    +  49    +  40
E       -----    ------    ----    -----    -----
E     -  -666     -3800      88      172     1028
E     +

/home/runner/boilerplate-arithmetic-formatter-1/test_module.py:77: AssertionError

i have no clue what the heck is happening since the test with 2 problems works fine

slightly different now but still what is going on

===================================== FAILURES =====================================
_________________ test_template[test_five_problems_with_solutions] _________________

arguments = [['32 - 698', '1 - 3801', '45 + 43', '123 + 49', '988 + 40'], True]
expected_output = '   32         1      45      123      988\n- 698    - 3801    + 43    +  49    +  40\n-----    ------    ----    -----    -----\n -666     -3800      88      172     1028'
fail_message = 'Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with five arithmetic problems and a second argument of `True`.'

>   ???
E   AssertionError: Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with five arithmetic problems and a second argument of `True`.
E   assert ('   32         1      45      123      988\n'\n '- 698    - 3801    + 43    +  49    +  40\n'\n '-----    ------    ----    -----    -----') == ('   32         1      45      123      988\n'\n '- 698    - 3801    + 43    +  49    +  40\n'\n '-----    ------    ----    -----    -----\n'\n ' -666     -3800      88      172     1028')
E          32         1      45      123      988
E       - 698    - 3801    + 43    +  49    +  40
E     - -----    ------    ----    -----    -----
E     ?                                          -
E     + -----    ------    ----    -----    -----
E     -  -666     -3800      88      172     1028

/home/runner/boilerplate-arithmetic-formatter-1/test_module.py:77: AssertionError
============================= short test summary info ==============================
FAILED test_module.py::test_template[test_five_problems_with_solutions] - Asserti...

it was a variable misnamed in the code

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