diff options
author | Prabhu Ramachandran | 2017-02-01 18:55:55 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2017-02-01 18:55:55 +0530 |
commit | 6012f3d3684a55bbef6a583453d5c17bdf843d68 (patch) | |
tree | 7d4e58b936ffacd0e08b80f473a2d610dce100ba /yaksh/evaluator_tests | |
parent | adc31775c1ca1481c6898fb8ef13548a14095d19 (diff) | |
download | online_test-6012f3d3684a55bbef6a583453d5c17bdf843d68.tar.gz online_test-6012f3d3684a55bbef6a583453d5c17bdf843d68.tar.bz2 online_test-6012f3d3684a55bbef6a583453d5c17bdf843d68.zip |
Fixes #190.
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r-- | yaksh/evaluator_tests/test_python_stdio_evaluator.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/yaksh/evaluator_tests/test_python_stdio_evaluator.py b/yaksh/evaluator_tests/test_python_stdio_evaluator.py new file mode 100644 index 0000000..db5028a --- /dev/null +++ b/yaksh/evaluator_tests/test_python_stdio_evaluator.py @@ -0,0 +1,62 @@ +from textwrap import dedent + +from yaksh.python_stdio_evaluator import compare_outputs + + +def test_compare_outputs(): + exp = "5\n5\n" + given = "5\n5\n" + success, msg = compare_outputs(given, exp) + assert success + + exp = "5\n5\n" + given = "5\n5" + success, msg = compare_outputs(given, exp) + assert success + + exp = "5\r5" + given = "5\n5" + success, msg = compare_outputs(given, exp) + assert success + + exp = " 5 \r 5 " + given = " 5 \n 5 " + success, msg = compare_outputs(given, exp) + assert success + + exp = "5\n5\n" + given = "5 5" + success, msg = compare_outputs(given, exp) + assert not success + m = dedent("""\ + ERROR: Got 1 lines in output, we expected 2. + Expected: + 5 + 5 + + Given: + 5 5 + """) + assert m == msg + + exp = "5\n5\n" + given = "5\n6" + success, msg = compare_outputs(given, exp) + assert not success + m = dedent("""\ + ERROR: + Expected: + 5 + 5 + + Given: + 5 + 6 + + Error in line 2 of output. + Expected line 2: + 5 + Given line 2: + 6 + """) + assert m == msg |