summaryrefslogtreecommitdiff
path: root/python/problems/while_and_if
diff options
context:
space:
mode:
authorMartin <martin@leo.fri1.uni-lj.si>2015-09-24 14:09:09 +0200
committerMartin <martin@leo.fri1.uni-lj.si>2015-09-24 14:09:09 +0200
commit4adc255e741171646d9f2ae6d3c058fc4e1456c3 (patch)
tree852c5bc677b6e7c5ac81f913eec69e2130461fbe /python/problems/while_and_if
parent93c4b0f9b87d4f251096ad0f94302048d92a9764 (diff)
Added to test function so that problematic test cases are returned.
Diffstat (limited to 'python/problems/while_and_if')
-rw-r--r--python/problems/while_and_if/buy_five/common.py13
-rw-r--r--python/problems/while_and_if/buy_five/sl.py3
-rw-r--r--python/problems/while_and_if/competition/common.py10
3 files changed, 18 insertions, 8 deletions
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)
diff --git a/python/problems/while_and_if/buy_five/sl.py b/python/problems/while_and_if/buy_five/sl.py
index ac90f74..0b5479d 100644
--- a/python/problems/while_and_if/buy_five/sl.py
+++ b/python/problems/while_and_if/buy_five/sl.py
@@ -2,7 +2,6 @@
import server
mod = server.problems.load_language('python', 'sl')
-
id = 185
name = 'Blagajna "vse po pet"'
slug = 'Blagajna "vse po pet"'
@@ -46,7 +45,7 @@ main_plan = ['''\
4. Izpiši vsoto.''']
while_clause = ['''\
-<p>Kako bi <b>prebral 5 cen</b> z uporabo zanke while?</p>''',
+<p>Kako bi nekaj <b>5x ponovil</b>?</p>''',
'''\
<p>Zanka while ima naslednjo sintakso:</p>
<pre>
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)