When a student submits code that breaks a test but it's not due to an assertion error, the feedback is either confusing or misleading.
For example, if a student has a simple KeyError mistake
def my_code(dataframe):
return dataframe['SalesPerson'] # assume SalesPerson is not a valid key
The test will fail but with the message:
"Test Failed: 'SalesPerson'
That really offers no help
Describe the solution you'd like
An easy solution is to provide the class of the exception or error:
"Test Failed: <class 'KeyError'> 'SalesPerson'\n"
The fix is simply in json_test_runner.py (buildResult) line 77
if err:
if err[0] is AssertionError:
output += "Test Failed: {0}\n".format(err[1])
else:
output += "Test Failed: {0} {1}\n".format(err[0], err[1])
# note that isinstance will NOT work here
Describe alternatives you've considered
A similar pull request
18
However with that solution you get the following:
"Test Failed: 'SalesPerson'\nhashtable_class_helper.pxi:pandas._libs.hashtable.PyObjectHashTable.get_item line 1627: \n"
In this context, the backtrace is not helpful to the student. Perhaps a config option?
Also, in that pull request it should not use isinstance() to test the error class.
(tested in python3.6).
When a student submits code that breaks a test but it's not due to an assertion error, the feedback is either confusing or misleading.
For example, if a student has a simple KeyError mistake
The test will fail but with the message:
That really offers no help
Describe the solution you'd like An easy solution is to provide the class of the exception or error:
The fix is simply in
json_test_runner.py (buildResult)
line 77Describe alternatives you've considered A similar pull request
18
However with that solution you get the following:
In this context, the backtrace is not helpful to the student. Perhaps a config option?
Also, in that pull request it should not use
isinstance()
to test the error class. (tested in python3.6).Additional context