diff options
author | Martin <martin@leo.fri1.uni-lj.si> | 2015-10-09 16:35:23 +0200 |
---|---|---|
committer | Martin <martin@leo.fri1.uni-lj.si> | 2015-10-09 16:35:23 +0200 |
commit | 95e107bf9e6a288969e4a83aee1a7062990f3b67 (patch) | |
tree | f69b15164a30d464f6f7b340634095716344b1ec /python/problems/lists_and_for/substrings | |
parent | fd31d7d74e58796f3a5a7c84b4b19cb4af59ef4c (diff) |
Fixed testing for most problems.
Diffstat (limited to 'python/problems/lists_and_for/substrings')
-rw-r--r-- | python/problems/lists_and_for/substrings/common.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/python/problems/lists_and_for/substrings/common.py b/python/problems/lists_and_for/substrings/common.py index 32a3d4c..bdc356a 100644 --- a/python/problems/lists_and_for/substrings/common.py +++ b/python/problems/lists_and_for/substrings/common.py @@ -27,12 +27,30 @@ hint_type = { } def test(python, code): - test_in = [1] + in_out = [ + ('a', ['', 'a']), + ('ab', ['', 'a', 'b', 'ab']), + ('abc', ['', 'a', 'b', 'c', 'ab', 'bc', 'abc']), + ('tema', ['', 't', 'e', 'm', 'a', 'te', 'em', 'ma', 'tem', 'ema', 'tema']), + ] + + test_in = [(None, s[0]+'\n') for s in in_out] + test_out = [str(s[1]) for s in in_out] + # List of outputs: (expression result, stdout, stderr, exception). + answers = python(code=code, inputs=test_in, timeout=1.0) + outputs = [ans[1] for ans in answers] + n_correct = 0 + tin = None + for i, (output, correct) in enumerate(zip(outputs, test_out)): + if correct in output: + n_correct += 1 + else: + tin = test_in[i][1] + tout = correct passed = n_correct == len(test_in) - tin = None - tout = None + 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)}}) |