MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_traceback_failure

Function test_traceback_failure

testing/test_assertion.py:1382–1434  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

1380
1381
1382def test_traceback_failure(pytester: Pytester) -> None:
1383 p1 = pytester.makepyfile(
1384 """
1385 def g():
1386 return 2
1387 def f(x):
1388 assert x == g()
1389 def test_onefails():
1390 f(3)
1391 """
1392 )
1393 result = pytester.runpytest(p1, "--tb=long")
1394 result.stdout.fnmatch_lines(
1395 [
1396 "*test_traceback_failure.py F*",
1397 "====* FAILURES *====",
1398 "____*____",
1399 "",
1400 " def test_onefails():",
1401 "> f(3)",
1402 "",
1403 "*test_*.py:6: ",
1404 "_ _ _ *",
1405 # "",
1406 " def f(x):",
1407 "> assert x == g()",
1408 "E assert 3 == 2",
1409 "E + where 2 = g()",
1410 "",
1411 "*test_traceback_failure.py:4: AssertionError",
1412 ]
1413 )
1414
1415 result = pytester.runpytest(p1) # "auto"
1416 result.stdout.fnmatch_lines(
1417 [
1418 "*test_traceback_failure.py F*",
1419 "====* FAILURES *====",
1420 "____*____",
1421 "",
1422 " def test_onefails():",
1423 "> f(3)",
1424 "",
1425 "*test_*.py:6: ",
1426 "",
1427 " def f(x):",
1428 "> assert x == g()",
1429 "E assert 3 == 2",
1430 "E + where 2 = g()",
1431 "",
1432 "*test_traceback_failure.py:4: AssertionError",
1433 ]
1434 )
1435
1436
1437def test_exception_handling_no_traceback(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected