Skip to content

Commit 5aa62c2

Browse files
committed
RF: refactor to allow return of test results
Break up testing function to allow return of individual test results.
1 parent e802bc6 commit 5aa62c2

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

gofer/ok.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
207207
return ''.join(random.choice(chars) for _ in range(size))
208208

209209

210-
def grade_notebook(notebook_path, tests_glob=None):
210+
def run_nb_tests(notebook_path, tests_glob=None):
211211
"""
212-
Grade a notebook file & return grade
212+
Run tests on a notebook and return score, test_results
213213
"""
214214
try:
215215
# Lots of notebooks call grade_notebook in them. These notebooks are then
@@ -256,7 +256,14 @@ def grade_notebook(notebook_path, tests_glob=None):
256256

257257
# avoid divide by zero error if there are no tests
258258
score = sum([r.grade for r in test_results])/max(len(test_results), 1)
259+
return score, test_results
259260

261+
262+
def grade_notebook(notebook_path, tests_glob=None):
263+
"""
264+
Grade a notebook file & return grade
265+
"""
266+
score, test_results = run_nb_tests(notebook_path, tests_glob)
260267
# If within an IPython or Jupyter environment, display hints
261268
display_defined = False
262269
try:

0 commit comments

Comments
 (0)