File: test_helpers.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 (33 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
import sys

import pytest


# the output is different in prior versions.
@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires python3.10 or higher")
def test_sequence_with_helper_funcs(pytester):
    """
    Should show a sequence of calls
    """
    pytester.copy_example("examples/test_example_helpers.py")
    result = pytester.runpytest("--check-max-tb=2")
    result.assert_outcomes(failed=1, passed=0)
    result.stdout.fnmatch_lines(
        [
            "*FAILURE: assert 1 == 0, first",
            "*in test_func() -> helper1()",
            "*in helper1() -> helper2()",
            "*in helper2() -> with check(\"first\"):",
            "*in helper2 -> assert 1 == 0",
            "*AssertionError: assert 1 == 0",


            "*FAILURE: assert 1 > 2, second",
            "*in test_func() -> helper1()",
            "*in helper1() -> helper2()",
            "*in helper2() -> with check(\"second\"):",
            "*in helper2 -> assert 1 > 2",
            "*AssertionError: assert 1 > 2"
        ],
    )