-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Defining the correct answer as a fixture is a useful pattern if it one needs to check the answer in multiple pytest tests. For example,
@pytest.fixture
def ans(sandbox: StudentFixture) -> ...:
s = sandbox.query_setup("s")
...
return # correct answer, could be a tuple of multiple parts
@pytest.mark.grading_data(name="Sigma", points=2)
def test_Sigma(sandbox: StudentFixture, ans: ...) -> None:
np.testing.assert_allclose(sandbox.query("Sigma"), ans[0])
@pytest.mark.grading_data(name="X", points=2)
def test_X(sandbox: StudentFixture, ans: ...) -> None:
np.testing.assert_allclose(sandbox.query("X"), ans[1])
# ... other similar tests follow
This generally works, but if the student code raises an Exception, students see,
Student code grading failed with an exception: Failed
Exception Message: Student code execution failed with an exception: TypeError
The backend stdout is:
info: container> _____________________ ERROR at setup of test_U[user_code] ______________________
info: container> Student code execution failed with an exception: TypeError
info: container> Exception Message: hello
Presumably because it fails in a fixture, in the setup, the backtrace doesn't get reported to the user?
Is accessing student code in a fixture a supported feature or not? It may be useful for questions in which there are multiple tests checking different aspects of essentially the same answer.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels