Arithmetic Formatter Project Help with Error Output

Hi. I need some help with this project.
When I run my code on my PC, using the test cases, the output “looks” fine.

In replit , I am failing only one test and don’t understand the error output – any direction would be great.

I copied the failing test input parameters to main.py before the auto test and I added
‘’‘print(repr (arithmetic_arranger ([“3 + 855”, “3801 - 2”, “45 + 43”, “123 + 49”])))’‘’
the output from the main.py test repr is:
‘’‘’’ 3 3801 45 123\n+ 855 - 2 + 43 + 49\n----- ------ ---- -----’
This shows a single newline – the test package assert remains the same and the test package test FAILS.

Here is the error output from the test package:

________________ test_template[test_four_problems_arrangement] _________________

arguments = [[]]
expected_output = '    3      3801      45      123\n+ 855    -    2    + 43    +  49\n-----    ------    ----    -----'
fail_message = 'Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "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 ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]
E       assert '\n\n' == ('    3      3801      45      123\n'\n '+ 855    -    2    + 43    +  49\n'\n '-----    ------    ----    -----')
E         Strings contain only whitespace, escaping them using repr()
E         - '    3      3801      45      123\n+ 855    -    2    + 43    +  49\n-----    ------    ----    -----'
E         + '\n\n'

test_module.py:77: AssertionError
=========================== short test summary info ============================
FAILED test_module.py::test_template[test_four_problems_arrangement] - Assert...
========================= 1 failed, 9 passed in 0.11s ===

Link to my code

Challenge: Arithmetic Formatter

Link to the challenge:

It seems to be saying that you are returning a string with only two newline characters. Hard to say why that’s happening without seeing your code.


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

How do I edit my own post. I can’t follow your user interface – very confused.

Thank you for the help.

Solution Found. Reloaded the template files and all tests passed.

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