예제 #1
0
def test_several_assignments_2(diff_assign_data):
    res = helper.run({
        **diff_assign_data, "DC_SCT":
        "Ex().check_object('df2').has_equal_value()"
    })
    assert not res["correct"]
    helper.no_line_info(res)
예제 #2
0
def test_without_highlighting(data, sct):
    data["DC_SCT"] = sct
    output = helper.run(data)
    assert not output["correct"]
    helper.no_line_info(output)
예제 #3
0
def test_parsing(name, ls, le, cs, ce):
    stu_code = """
if True:
    a = 1

if False:
    b = 2
else:
    c = 3

for i in range(2):
    d = 4

x = 2
while x > 0:
    e = 5
    x -= 1

try:
    f = 6
except:
    pass

try:
    g = 7
except:
    pass
finally:
    h = 8

# 2 assignments
i = 9
if True:
    i = 9
"""
    sol_code = """
if True:
    a = 10

if False:
    b = 20
else:
    c = 30

for i in range(2):
    d = 40

x = 2
while x > 0:
    e = 50
    x -= 1

try:
    f = 60
except:
    pass

try:
    g = 70
except:
    pass
finally:
    h = 80

# 2 assignments
i = 90
if True:
    i = 90
"""
    res = helper.run(
        {
            "DC_CODE": stu_code,
            "DC_SOLUTION": sol_code,
            "DC_SCT": 'Ex().check_object("%s").has_equal_value()' % name,
        }
    )
    assert not res["correct"]
    if name == "i":
        helper.no_line_info(res)
    else:
        helper.with_line_info(res, ls, le, cs, ce)