summaryrefslogtreecommitdiff
path: root/python/problems/lists_and_for
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/lists_and_for
parent93c4b0f9b87d4f251096ad0f94302048d92a9764 (diff)
Added to test function so that problematic test cases are returned.
Diffstat (limited to 'python/problems/lists_and_for')
-rw-r--r--python/problems/lists_and_for/contains_42/common.py14
-rw-r--r--python/problems/lists_and_for/contains_42/sl.py6
-rw-r--r--python/problems/lists_and_for/contains_string/common.py21
-rw-r--r--python/problems/lists_and_for/contains_string/sl.py6
4 files changed, 29 insertions, 18 deletions
diff --git a/python/problems/lists_and_for/contains_42/common.py b/python/problems/lists_and_for/contains_42/common.py
index 3ebe546..915938e 100644
--- a/python/problems/lists_and_for/contains_42/common.py
+++ b/python/problems/lists_and_for/contains_42/common.py
@@ -48,6 +48,7 @@ def test(python, code):
]
n_correct = 0
+ tin = None
for xs_i, xs in enumerate(test_xs):
# change code to contain new xs instead of the one
# given by user
@@ -63,15 +64,20 @@ def test(python, code):
if str(test_out[xs_i]) in output and \
str(not test_out[xs_i]) not in output:
n_correct += 1
-
- passed = n_correct == len(test_in)
- hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ else:
+ tin = test_xs[xs_i]
+ tout = test_out[xs_i]
+
+ passed = n_correct == len(test_xs)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_xs)}}]
+ 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
answer = python(code=code, inputs=[(None, None)], 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/lists_and_for/contains_42/sl.py b/python/problems/lists_and_for/contains_42/sl.py
index eaf9609..9477e29 100644
--- a/python/problems/lists_and_for/contains_42/sl.py
+++ b/python/problems/lists_and_for/contains_42/sl.py
@@ -51,7 +51,7 @@ videl42 = False
<p>in jo tekom zanke ustrezno spremenimo.''']
plan = ['''\
-<p><b>Plan.</b> Če bi morali nekomu povedati, kako naj se loti te naloge, bi mu lahko rekli:</p>
+<p><b>Plan.</b> Kako bi se tega lotil ročno? Nekako takole: </p>
<pre>
Za vsak element v seznamu
Poglej, ali je 42?
@@ -73,9 +73,9 @@ hint = {
'if_clause': if_clause,
'printing': ['''\
-<p>Izpišite rezultat.</p>'''],
+<p>Izpiši rezultat.</p>'''],
'print_out_for': ['''\
-<p>Pazite, da izpišete rezultat izven zanke!</p>''']
+<p>Pazi, da izpišeš rezultat izven zanke!</p>''']
}
diff --git a/python/problems/lists_and_for/contains_string/common.py b/python/problems/lists_and_for/contains_string/common.py
index 5e0a46b..0fe7c00 100644
--- a/python/problems/lists_and_for/contains_string/common.py
+++ b/python/problems/lists_and_for/contains_string/common.py
@@ -30,12 +30,12 @@ hint_type = {
}
def test(python, code):
- test_xs = [['foo', 'bar', 'baz', 'Waldo', 'foobar'],
+ test_xs = [['waldo', 'foo', 'bar', 'baz'],
+ ['foo', 'bar', 'baz', 'Waldo', 'foobar'],
['foo', 'bar', 'baz', 'Waldo'],
['Waldo', 'foo', 'bar', 'baz'],
[],
- ['Waldo'],
- ['waldo', 'foo', 'bar', 'baz']]
+ ['Waldo']]
test_out = [
True,
True,
@@ -46,6 +46,7 @@ def test(python, code):
]
n_correct = 0
+ tin = None
for xs_i, xs in enumerate(test_xs):
# change code to contain new xs instead of the one
# given by user
@@ -61,19 +62,23 @@ def test(python, code):
if str(test_out[xs_i]) in output and \
str(not test_out[xs_i]) not in output:
n_correct += 1
-
- passed = n_correct == len(test_in)
- hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ else:
+ tin = test_xs[xs_i]
+ tout = test_out[xs_i]
+
+ passed = n_correct == len(test_xs)
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_xs)}}]
+ 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
answer = python(code=code, inputs=[(None, None)], timeout=1.0)
- exc = get_exception_desc(answer)
+ exc = get_exception_desc(answer[0][3])
if exc: return exc
tokens = get_tokens(code)
- print(tokens)
# if has no xs, tell him to ask for values
if not has_token_sequence(tokens, ['xs', '=', '[']):
diff --git a/python/problems/lists_and_for/contains_string/sl.py b/python/problems/lists_and_for/contains_string/sl.py
index 5d42784..2f24458 100644
--- a/python/problems/lists_and_for/contains_string/sl.py
+++ b/python/problems/lists_and_for/contains_string/sl.py
@@ -40,7 +40,7 @@ if x == 'Waldo':
</pre>''']
plan = ['''\
-<p><b>Plan.</b> je enak kot pri prvi nalogi:
+<p><b>Plan</b> je enak kot pri prvi nalogi:
<pre>
Za vsak element v seznamu
Poglej, ali je element enak 'Waldo'?
@@ -60,9 +60,9 @@ hint = {
'if_clause': if_clause,
'printing': ['''\
-<p>Izpišite rezultat!</p>'''],
+<p>Izpiši rezultat!</p>'''],
'print_out_for': ['''\
-<p>Pazite, da izpišete rezultat izven zanke!</p>''']
+<p>Pazi, da izpišeš rezultat izven zanke!</p>''']
}