Repository navigation
Add student_source() for inspecting the submission - #61
Merged
Merged
Conversation
StudentFixture.student_source() returns the student's submitted source as a string, a documented way to inspect the submission itself (for example with ast) instead of reaching for the student_code_file path. For a notebook it returns the graded cells' code, the same source that runs in the sandbox, so .py and .ipynb questions use the same call. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
eliotwrobson
marked this pull request as ready for review
November 20, 2026 07:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
StudentFixture.student_source(), a documented way for a test to read the student's submitted source as a string and inspect it — typically withast— instead of reaching for the semi-internalstudent_code_filepath.It returns only the student's file (not any
leading_code.py/trailing_code.pythe question wraps around it). For a notebook submission it returns the graded cells' code, selected bynotebook_cell_tagwhen one is set — the same source that runs in the sandbox — so.pyand.ipynbquestions use the same call.This supports converting legacy questions that statically analyze the submission (e.g. CS357's
11-Sparse/Sparse-COO-*, which read/grade/student/user_code.pyand parse it to check how a result was built).Testing
test_student_sourcescenario: a.pysubmission read back through the full sandbox, asserting the text matches and thatastfinds the function and a matmul.test_student_source_notebookscenario: a notebook submission returns only the#gradecell's code, not a scratch cell.🤖 Generated with Claude Code