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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
def test_baseline(pytester):
pytester.copy_example("examples/test_example_multiple_failures.py")
result = pytester.runpytest("--check-max-tb=10")
result.assert_outcomes(failed=1)
result.stdout.fnmatch_lines(
[
"*FAILURE: * 7 == 100",
"*test_multiple_failures() -> check.equal(i, 100)",
"*FAILURE: * 8 == 100",
"*test_multiple_failures() -> check.equal(i, 100)",
"*FAILURE: * 9 == 100",
"*test_multiple_failures() -> check.equal(i, 100)",
"Failed Checks: 10",
],
)
def test_no_tb(pytester):
pytester.copy_example("examples/test_example_multiple_failures.py")
result = pytester.runpytest("--check-max-tb=0")
result.assert_outcomes(failed=1)
result.stdout.fnmatch_lines(
[
"*FAILURE: * 7 == 100",
"*FAILURE: * 8 == 100",
"*FAILURE: * 9 == 100",
"Failed Checks: 10",
],
)
result.stdout.no_fnmatch_line("*test_multiple_failures() -> check.equal(i, 100)")
def test_max_report(pytester):
pytester.copy_example("examples/test_example_multiple_failures.py")
result = pytester.runpytest("--check-max-report=5")
result.assert_outcomes(failed=1)
result.stdout.fnmatch_lines(
[
"*FAILURE: * 1 == 100",
"*FAILURE: * 2 == 100",
"*FAILURE: * 3 == 100",
"*FAILURE: * 4 == 100",
"*FAILURE: * 5 == 100",
"Failed Checks: 10",
],
)
result.stdout.no_fnmatch_line("*FAILURE: * 6 == 100")
def test_max_fail(pytester):
pytester.copy_example("examples/test_example_multiple_failures.py")
result = pytester.runpytest("--check-max-fail=5")
result.assert_outcomes(failed=1)
result.stdout.fnmatch_lines(
[
"*FAILURE: * 1 == 100",
"*FAILURE: * 2 == 100",
"*FAILURE: * 3 == 100",
"*FAILURE: * 4 == 100",
"*FAILURE: * 5 == 100",
"Failed Checks: 5",
"*AssertionError: pytest-check max fail of 5 reached",
],
)
result.stdout.no_fnmatch_line("*FAILURE: * 6 == 100")
def test_max_tb(pytester):
pytester.copy_example("examples/test_example_multiple_failures.py")
result = pytester.runpytest("--check-max-tb=2", "--show-capture=no")
result.assert_outcomes(failed=1)
num_tb = str(result.stdout).count("test_multiple_failures() -> check.equal(i, 100)")
assert num_tb == 2
|