-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot access source code in tests #229
Comments
I believe #231 fixes this issue. Can you try installing that version of Otter and let me know if it works?
|
Doesn't seem to work. I've made a minimal example and tested (ast_test.ipynb.zip). The issue seems to be that doctest can't find the source because it never exists in a file.
Inside of doctest they play some tricks with the linecache to allow access to the source but only when debugging. The two options I can think of at the moment are:
I'm a bit busy at the moment (writing exams with otter!) but I might be able to take a look at a later date. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I think I've implemented a fix for this while refactoring our execution internals for v4. The fix uses |
Is your feature request related to a problem? Please describe.
I'm aiming to walk an ast in a test but cannot access the source of the function for example using
inspect.getsource(some_function)
. This results in aOSError: source code not available
presumably because we only have access to a compiled object within the grading framework (everything works fine in the original notebook).In general there seems to be no way to access an ast of the solution cell even though it seems otter generates this to do the evaluation (based on this: https://otter-grader.readthedocs.io/en/latest/execution.html).
Describe the solution you'd like
It would be useful to natively support
inspect.getsource
within the grader, maybe doing some 'injection' like with the random number seeding.Describe alternatives you've considered
Possibly allowing access to the ast at least within a test .py file (even if not in the notebook format) as an advanced feature.
The text was updated successfully, but these errors were encountered: