diff options
author | Martin <martin@leo.fri1.uni-lj.si> | 2015-09-24 14:09:09 +0200 |
---|---|---|
committer | Martin <martin@leo.fri1.uni-lj.si> | 2015-09-24 14:09:09 +0200 |
commit | 4adc255e741171646d9f2ae6d3c058fc4e1456c3 (patch) | |
tree | 852c5bc677b6e7c5ac81f913eec69e2130461fbe /python/problems/while_and_if/competition | |
parent | 93c4b0f9b87d4f251096ad0f94302048d92a9764 (diff) |
Added to test function so that problematic test cases are returned.
Diffstat (limited to 'python/problems/while_and_if/competition')
-rw-r--r-- | python/problems/while_and_if/competition/common.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/python/problems/while_and_if/competition/common.py b/python/problems/while_and_if/competition/common.py index 4be8b12..a7471df 100644 --- a/python/problems/while_and_if/competition/common.py +++ b/python/problems/while_and_if/competition/common.py @@ -45,19 +45,25 @@ def test(python, code): outputs = [ans[1] for ans in answers] n_correct = 0 - for output, correct in zip(outputs, test_out): + tin = None + for i, (output, correct) in enumerate(zip(outputs, test_out)): if string_almost_equal(output, correct): n_correct += 1 + else: + tin = test_in[i][1] + tout = correct passed = n_correct == len(test_in) hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}] + if tin: + hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}}) return passed, hints def hint(python, code): # run one test first to see if there are any exceptions test_in = [(None, '5\n1\n1\n1\n1\n1\n')] answer = python(code=code, inputs=test_in, timeout=1.0) - exc = get_exception_desc(answer) + exc = get_exception_desc(answer[0][3]) if exc: return exc tokens = get_tokens(code) |