File: test_red.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 (31 lines) | stat: -rw-r--r-- 941 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
def test_red(pytester):
    """
    Should have red in failure.
    """
    pytester.copy_example("examples/test_example_simple.py")
    result = pytester.runpytest("--color=yes")
    result.assert_outcomes(failed=1, passed=1)
    result.stdout.fnmatch_lines(
        [
            "*[31mFAILURE:*[0massert*",
            "*[31mtest_example_simple.py*[0m:14 in test_fail*",
            "*[31mAssertionError: assert 1 == 2*",
            "*[0m*"
        ],
    )


def test_no_red(pytester):
    """
    Should NOT have red in failure.
    """
    pytester.copy_example("examples/test_example_simple.py")
    result = pytester.runpytest("--color=no")
    result.assert_outcomes(failed=1, passed=1)
    result.stdout.fnmatch_lines(
        [
            "*FAILURE: assert*",  # no red before assert
        ],
    )
    result.stdout.no_fnmatch_line("*[31m*")  # no red anywhere
    result.stdout.no_fnmatch_line("*[0m*")  # no reset anywhere