From 4adc255e741171646d9f2ae6d3c058fc4e1456c3 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 24 Sep 2015 14:09:09 +0200 Subject: Added to test function so that problematic test cases are returned. --- python/problems/while_and_if/buy_five/common.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'python/problems/while_and_if/buy_five/common.py') diff --git a/python/problems/while_and_if/buy_five/common.py b/python/problems/while_and_if/buy_five/common.py index 84be034..9f335af 100644 --- a/python/problems/while_and_if/buy_five/common.py +++ b/python/problems/while_and_if/buy_five/common.py @@ -19,7 +19,6 @@ print('Vsota:', vsota) ''' hint_type = { - 'plan': HintSequence('plan', 5), 'printing': Hint('printing'), 'while_clause': Hint('while_clause'), 'reading_while': Hint('reading_while'), @@ -41,7 +40,7 @@ def test(python, code): 5, 15, 5, - 29, + 30, 0, ] @@ -50,19 +49,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, '1\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) -- cgit v1.2.1