Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Error Messages (easy version) #19

Open
habermanUIUC opened this issue Dec 4, 2020 · 0 comments
Open

Better Error Messages (easy version) #19

habermanUIUC opened this issue Dec 4, 2020 · 0 comments

Comments

@habermanUIUC
Copy link

habermanUIUC commented Dec 4, 2020

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).

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant