Skip to content

Commit

Permalink
Added a test for correct behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
tuncbkose authored and brichet committed Mar 6, 2023
1 parent 6706939 commit 52e88e5
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
75 changes: 75 additions & 0 deletions nbgrader/tests/apps/files/validation-zero-points.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Validating this file should fail even though the assignment has 0 points."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "8f1eab8d02a9520920aa06f8a86a2492",
"grade": false,
"grade_id": "squares",
"locked": false,
"schema_version": 3,
"solution": true
}
},
"outputs": [],
"source": [
"def squares(n):\n",
" # YOUR CODE HERE\n",
" return [0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"grade": true,
"grade_id": "correct_squares",
"locked": true,
"points": 0,
"schema_version": 3,
"solution": false,
"task": false
},
"tags": []
},
"outputs": [],
"source": [
"assert squares(1) == [1]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
6 changes: 6 additions & 0 deletions nbgrader/tests/apps/test_nbgrader_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def test_validate_subdir(self):
output = run_nbgrader(["validate", "my_subdir/open_relative_file.ipynb"], stdout=True)
assert output.strip() == "Success! Your notebook passes all the tests."

def test_validate_zero_points(self):
"""Does validation correctly fail when cell has zero points?"""
self._copy_file(join("files", "validation-zero-points.ipynb"), "validation-zero-points.ipynb")
output = run_nbgrader(["validate", "validation-zero-points.ipynb"], stdout=True)
assert output.splitlines()[0] == "VALIDATION FAILED ON 1 CELL(S)! If you submit your assignment as it is, you WILL NOT"

def test_invert_validate_unchanged(self):
"""Does the inverted validation pass on an unchanged notebook?"""
self._copy_file(join("files", "submitted-unchanged.ipynb"), "submitted-unchanged.ipynb")
Expand Down

0 comments on commit 52e88e5

Please sign in to comment.