2009-09-06 22:59:39 +08:00
|
|
|
def test_functional(testdir):
|
|
|
|
testdir.makepyfile("""
|
|
|
|
def test_hello():
|
|
|
|
x = 3
|
|
|
|
assert x == 4
|
|
|
|
""")
|
|
|
|
result = testdir.runpytest()
|
2010-07-27 03:15:15 +08:00
|
|
|
assert "3 == 4" in result.stdout.str()
|
2009-09-06 22:59:39 +08:00
|
|
|
result = testdir.runpytest("--no-assert")
|
2010-07-27 03:15:15 +08:00
|
|
|
assert "3 == 4" not in result.stdout.str()
|
2009-09-06 22:59:39 +08:00
|
|
|
|
2010-07-29 18:55:39 +08:00
|
|
|
def test_triple_quoted_string_issue113(testdir):
|
|
|
|
testdir.makepyfile("""
|
|
|
|
def test_hello():
|
|
|
|
assert "" == '''
|
|
|
|
'''""")
|
|
|
|
result = testdir.runpytest("--fulltrace")
|
|
|
|
result.stdout.fnmatch_lines([
|
|
|
|
"*1 failed*",
|
|
|
|
])
|
|
|
|
assert 'SyntaxError' not in result.stdout.str()
|
|
|
|
|
2009-09-06 22:59:39 +08:00
|
|
|
def test_traceback_failure(testdir):
|
|
|
|
p1 = testdir.makepyfile("""
|
|
|
|
def g():
|
|
|
|
return 2
|
|
|
|
def f(x):
|
|
|
|
assert x == g()
|
|
|
|
def test_onefails():
|
|
|
|
f(3)
|
|
|
|
""")
|
|
|
|
result = testdir.runpytest(p1)
|
|
|
|
result.stdout.fnmatch_lines([
|
2010-07-27 03:15:15 +08:00
|
|
|
"*test_traceback_failure.py F",
|
2009-09-06 22:59:39 +08:00
|
|
|
"====* FAILURES *====",
|
2010-07-27 03:15:15 +08:00
|
|
|
"____*____",
|
2009-09-06 22:59:39 +08:00
|
|
|
"",
|
|
|
|
" def test_onefails():",
|
|
|
|
"> f(3)",
|
|
|
|
"",
|
|
|
|
"*test_*.py:6: ",
|
|
|
|
"_ _ _ *",
|
|
|
|
#"",
|
|
|
|
" def f(x):",
|
|
|
|
"> assert x == g()",
|
|
|
|
"E assert 3 == 2",
|
|
|
|
"E + where 2 = g()",
|
|
|
|
"",
|
|
|
|
"*test_traceback_failure.py:4: AssertionError"
|
|
|
|
])
|
|
|
|
|