File: test_maxfail.py

package info (click to toggle)
pytest-check 2.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 432 kB
  • sloc: python: 1,775; sh: 17; makefile: 6
file content (34 lines) | stat: -rw-r--r-- 1,036 bytes parent folder | download | duplicates (2)
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
def test_maxfail_1_stops_on_first_check(pytester):
    """
    Should stop after first failed check
    """
    pytester.copy_example("examples/test_example_maxfail.py")
    result = pytester.runpytest("--maxfail=1")
    result.assert_outcomes(failed=1, passed=0)
    result.stdout.fnmatch_lines(["*AssertionError: one*"])


def test_maxfail_2_stops_on_two_failed_tests(pytester):
    """
    Should stop after 2 tests (not checks)
    """
    pytester.copy_example("examples/test_example_maxfail.py")
    result = pytester.runpytest("--maxfail=2")
    result.assert_outcomes(failed=2, passed=0)
    result.stdout.fnmatch_lines(
        [
            "*FAILURE: one",
            "*FAILURE: two",
            "*FAILURE: three",
            "*Failed Checks: 3*",
        ],
    )


def test_maxfail_3_runs_at_least_3_tests(pytester):
    """
    Should not stop on checks.
    """
    pytester.copy_example("examples/test_example_maxfail.py")
    result = pytester.runpytest("--maxfail=3")
    result.assert_outcomes(failed=2, passed=1)