summaryrefslogtreecommitdiff
path: root/yaksh/evaluator_tests/test_python_stdio_evaluator.py
blob: db2fd697c3df438ca3719bfcf1d951bf5261ba08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from yaksh.error_messages 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)
    error_msg = msg.get('error_msg')
    assert not success
    m = ("Incorrect Answer: We had expected 1 number of lines. " +
         "We got 2 number of lines.")
    assert m == error_msg

    exp = "5\n5\n"
    given = "5\n6"
    success, msg = compare_outputs(given, exp)
    error_msg = msg.get('error_msg')
    m = "Incorrect Answer: Line number(s) 2 did not match."
    assert not success
    assert m == error_msg