The pytest results being passed back aren't very helpful because they don't include enough constructive feedback to improve the code submission on the next attempt. For example, we can get the outcome:
test_program.py::test_hat_variables - AttributeError: module 'program'...
Pytest reported one or more failed assertions
and in this example, the failed assertion isn't printing in full. Here is the associated test file:
# codewit_test.py
import sys
def test_hat_variables():
sys.modules.pop("program", None)
import py_code
assert py_code.HatName == "Veracruz"
assert py_code.NumberOfHats == 9
assert py_code.CostOfHats == 278.91
assert py_code.WearingHat is False
The real, full assertion failure message is:
assert program.HatName == "Veracruz"
^^^^^^^^^^^^^^^
E AttributeError: module 'program' has no attribute 'HatName'
The tests will be revised with more protection for checking attribute existence as well as a customized (and constructively-worded) assertion message, such as:
assert hasattr(program, HatName), "there should be a variable named exactly HatName"
assert program.HatName == "Veracruz", f"HatName should have the value \"Veracruz\" but is {program.HatName}"
However, the full assertion message (i.e. "there should be a variable named exactly HatName" or f"HatName should have the value "Veracruz" but is {program.HatName}) should be reported instead of a truncated outcome.
The pytest results being passed back aren't very helpful because they don't include enough constructive feedback to improve the code submission on the next attempt. For example, we can get the outcome:
and in this example, the failed assertion isn't printing in full. Here is the associated test file:
The real, full assertion failure message is:
The tests will be revised with more protection for checking attribute existence as well as a customized (and constructively-worded) assertion message, such as:
However, the full assertion message (i.e. "there should be a variable named exactly HatName" or f"HatName should have the value "Veracruz" but is {program.HatName}) should be reported instead of a truncated outcome.