ucbds-infra / otter-grader

A Python and R autograding solution
https://otter-grader.readthedocs.io
BSD 3-Clause "New" or "Revised" License
126 stars 66 forks source link

Make test functions get access to global variables #837

Closed muhangao closed 2 months ago

muhangao commented 2 months ago

I'm writing test functions for autograder using OK Test format. However, for some functions, there're variable not defined error.

I tried to define them again in the test['setup'], and it's not working. I'm wondering is there any way to make test functions get access to global variables?

muhangao commented 2 months ago

Never mind, after adding nltk.download('punkt_tab') everything works.

chrispyles commented 2 months ago

Just adding info for the benefit of anyone who comes across this issue:

Otter does not support sharing variables declared in tests across test cases; there is an open FR for this (#426) but it is not currently planned. Otter also does not support all fields of the OK test format (including setup and teardown).

muhangao commented 2 months ago

Let me make sure I understand: So can the test function gain access to variables created by students?

chrispyles commented 2 months ago

Yes, anything declared in the student code should be accessible, you just can’t share variables between test cases that aren’t in the student code.