File: test_any_failures.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 (41 lines) | stat: -rw-r--r-- 1,045 bytes parent folder | download
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
from typing import Callable

from pytest_check import any_failures, check


def test_any_failures_returns_true_when_checks_fail(run_example_test: Callable) -> None:
    result = run_example_test("test_example_any_failures.py", "test_any_failures_false")
    result.assert_outcomes(failed=1, passed=0)
    result.stdout.fnmatch_lines(
        [
            "*check 1 == 2*",
            "*check 1 == 3*",
            "*check 1 == 4*",
            "*Failed Checks: 3",
        ],
    )


def test_any_failures_returns_true_when_single_check_fails(
    run_example_test: Callable,
) -> None:
    result = run_example_test("test_example_any_failures.py", "test_any_failures_true")
    result.assert_outcomes(failed=1, passed=0)
    result.stdout.fnmatch_lines(
        [
            "*check 2 == 3*",
            "*Failed Checks: 1",
        ],
    )


def test_top_level():
    assert not any_failures()


def test_from_imported_check():
    assert not check.any_failures()


def test_from_check_fixture(check):
    assert not check.any_failures()