Hi,
I have gotten my code to work in another file by calling on the test values in the function.
The test looks incorrect to me because it is passing 5 problems in a test that is supposed to only have 2 and the same for the other which is making it fail the operator test.
When running the tests I get these 2 error messages:
pytest
=================== test session starts ====================
platform linux -- Python 3.10.8, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/runner/boilerplate-arithmetic-formatter-8
collected 10 items
test_module.py .....F..F. [100%]
========================= FAILURES =========================
__________ test_template[test_incorrect_operator] __________
arguments = [['3 / 855', '3801 - 2', '45 + 43', '123 + 49']]
expected_output = "Error: Operator must be '+' or '-'."
fail_message = 'Expected calling "arithmetic_arranger()" with a problem that uses the "/" operator to return "Error: Operator must be \'+\' or \'-\'."'
@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 calling "arithmetic_arranger()" with a problem that uses the "/" operator to return "Error: Operator must be '+' or '-'."
E assert ' 3 3...--- ------' == "Error: Opera...e '+' or '-'."
E - Error: Operator must be '+' or '-'.
E + 3 3801 45 123 1
E + / 855 - 2 + 43 + 49 - 9380
E + ----- ------ ---- ----- ------
test_module.py:77: AssertionError
------------------- Captured stdout call -------------------
problem length: 4
op count : 0
op1 /
op2 -
op3 +
op4 +
op5 -
1
2
3
4
4
_____ test_template[test_two_problems_with_solutions] ______
arguments = [['3 + 855', '988 + 40'], True]
expected_output = ' 3 988\n+ 855 + 40\n----- -----\n 858 1028'
fail_message = 'Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with ["3 + 855", "988 + 40"] and a second argument of `True`.'
@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 solutions to be correctly displayed in output when calling "arithmetic_arranger()" with ["3 + 855", "988 + 40"] and a second argument of `True`.
E assert ' 3 9...172 -9379' == ' 3 9... 858 1028'
E - 3 988
E - + 855 + 40
E - ----- -----
E - 858 1028
E + 3 988 45 123 1
E + + 855 + 40 + 43 + 49 - 9380
E + ----- ----- ---- ----- ------...
E
E ...Full output truncated (2 lines hidden), use '-vv' to show
test_module.py:77: AssertionError
------------------- Captured stdout call -------------------
problem length: 2
op count : 0
op1 +
op2 +
op3 +
op4 +
op5 -
1
2
3
4
5
5
================= short test summary info ==================
FAILED test_module.py::test_template[test_incorrect_operator]
FAILED test_module.py::test_template[test_two_problems_with_solutions]
=============== 2 failed, 8 passed in 0.19s ================
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Challenge: Scientific Computing with Python Projects - Arithmetic Formatter
Link to the challenge: