예제 #1
0
def test_trivial():
    expected = """
user1()
user2()
if user3():
    print("Y")
"""

    c = C(dummy_trivial)
    x = c(io.StringIO(user_code)).getvalue()
    assert (x == expected)
예제 #2
0
def test_complex():
    expected = """
if sys:
    user1()
    user2()
    if user3():
        print("Y")
"""

    c = C(dummy_complex)
    x = c(io.StringIO(user_code)).getvalue()
    assert (x == expected)
예제 #3
0
def test_simple():
    expected = """
print("X")
user1()
user2()
if user3():
    print("Y")
"""

    c = C(dummy_simple)
    x = c(io.StringIO(user_code)).getvalue()
    assert (x == expected)
예제 #4
0
def test_pass():
    expected = """
if sys:
    user1()
    user2()
    if user3():
        print("Y")
pass
if other:
    pass
"""

    c = C(dummy_pass)
    x = c(io.StringIO(user_code)).getvalue()
    assert (x == expected)
예제 #5
0
def test_empty():
    with pytest.raises(ValueError) as ve:
        C(dummy_empty)
    assert ("No insertion line" in str(ve.value))
예제 #6
0
def test_invalid_format():
    with pytest.raises(ValueError) as ve:
        C(dummy_header)
    assert ("'# ---  END  TEMPLATE ---' is not in" in str(ve.value))
예제 #7
0
def test_multiple():
    with pytest.raises(ValueError) as ve:
        C(dummy_multiple)
    assert ("Multiple insertion" in str(ve.value))