Closed lrfinotti closed 1 month ago
Interesting, it looks like a confluence of things is causing this bug. Because the only test case for the question is hidden, Otter by default doesn't include a check cell for the question after the solution cell, so all tests will get run at the end of the notebook. However, in order to run the tests, Otter's generated code reassigns the variable t
:
from otter.execute import Checker
for t in ["./tests/q1.py"]:
Checker.check_if_not_already_checked(t)
from otter.test_files import GradingResults
results = GradingResults(Checker.get_results())
import pickle
with open("/var/folders/c_/j_t422q90tq1fx3pc0r70jgw0000gn/T/tmp2b9m3vx7.pkl", "wb") as f:
pickle.dump(results, f)
so t
is no longer 1
when the test is run. It should be relatively simple to change the loop variable to something that won't cause collisions (i.e. a variable with a random name).
It seems that one cannot use a variable named
t
on a test.If you have something like
and then a test like
you get an error. (Maybe a problem with conflicting variable names?) See the very simple attached file as an example. bug.zip (The ZIP file contains only a very simple notebook.)
Here is the output of trying to create an assignment:
Simple renaming the variable to something else, like
tt
makes it work.I'm using Python 3.11.9 (from Debian Sid) and otter 5.5.0.
If relevant:
I can get around the issue (by renaming the variable), but I thought I should make the developers aware.