File: test_example_maxfail.py

package info (click to toggle)
pytest-check 2.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 480 kB
  • sloc: python: 2,220; sh: 17; makefile: 6
file content (36 lines) | stat: -rw-r--r-- 769 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
35
36
"""
Running: pytest --maxfail=1 test_example_maxfail.py
Should cause pytest to stop after the first failed check in test_a

Running: pytest --maxfail=2 test_example_maxfail.py
Should run a and b, but not c

Running: pytest --maxfail=3 test_example_maxfail.py
Should run a, b, and c

This is because pytest-check has a special case for maxfail==1.
If maxfail==1, stop on the first failed check.
If > 1, run until 2 failed "tests", not "checks".
"""

from pytest_check import check


def test_a():
    "Failing test: 3 failed checks"
    with check:
        assert False, "one"
    with check:
        assert False, "two"
    with check:
        assert False, "three"


def test_b():
    "Failing test"
    assert False


def test_c():
    "Passing test"
    assert True