Skip to content

Commit 52e88e5

Browse files
tuncbkosebrichet
authored andcommitted
Added a test for correct behavior
1 parent 6706939 commit 52e88e5

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Validating this file should fail even though the assignment has 0 points."
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {
14+
"deletable": false,
15+
"nbgrader": {
16+
"checksum": "8f1eab8d02a9520920aa06f8a86a2492",
17+
"grade": false,
18+
"grade_id": "squares",
19+
"locked": false,
20+
"schema_version": 3,
21+
"solution": true
22+
}
23+
},
24+
"outputs": [],
25+
"source": [
26+
"def squares(n):\n",
27+
" # YOUR CODE HERE\n",
28+
" return [0]"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": null,
34+
"metadata": {
35+
"deletable": false,
36+
"editable": false,
37+
"nbgrader": {
38+
"grade": true,
39+
"grade_id": "correct_squares",
40+
"locked": true,
41+
"points": 0,
42+
"schema_version": 3,
43+
"solution": false,
44+
"task": false
45+
},
46+
"tags": []
47+
},
48+
"outputs": [],
49+
"source": [
50+
"assert squares(1) == [1]"
51+
]
52+
}
53+
],
54+
"metadata": {
55+
"kernelspec": {
56+
"display_name": "Python 3 (ipykernel)",
57+
"language": "python",
58+
"name": "python3"
59+
},
60+
"language_info": {
61+
"codemirror_mode": {
62+
"name": "ipython",
63+
"version": 3
64+
},
65+
"file_extension": ".py",
66+
"mimetype": "text/x-python",
67+
"name": "python",
68+
"nbconvert_exporter": "python",
69+
"pygments_lexer": "ipython3",
70+
"version": "3.10.10"
71+
}
72+
},
73+
"nbformat": 4,
74+
"nbformat_minor": 4
75+
}

nbgrader/tests/apps/test_nbgrader_validate.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ def test_validate_subdir(self):
2929
output = run_nbgrader(["validate", "my_subdir/open_relative_file.ipynb"], stdout=True)
3030
assert output.strip() == "Success! Your notebook passes all the tests."
3131

32+
def test_validate_zero_points(self):
33+
"""Does validation correctly fail when cell has zero points?"""
34+
self._copy_file(join("files", "validation-zero-points.ipynb"), "validation-zero-points.ipynb")
35+
output = run_nbgrader(["validate", "validation-zero-points.ipynb"], stdout=True)
36+
assert output.splitlines()[0] == "VALIDATION FAILED ON 1 CELL(S)! If you submit your assignment as it is, you WILL NOT"
37+
3238
def test_invert_validate_unchanged(self):
3339
"""Does the inverted validation pass on an unchanged notebook?"""
3440
self._copy_file(join("files", "submitted-unchanged.ipynb"), "submitted-unchanged.ipynb")

0 commit comments

Comments
 (0)