MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_fixtures_in_conftest

Function test_fixtures_in_conftest

testing/python/show_fixtures_per_test.py:39–82  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

37
38
39def test_fixtures_in_conftest(pytester: Pytester) -> None:
40 pytester.makeconftest(
41 '''
42 import pytest
43 @pytest.fixture
44 def arg1():
45 """arg1 docstring"""
46 @pytest.fixture
47 def arg2():
48 """arg2 docstring"""
49 @pytest.fixture
50 def arg3(arg1, arg2):
51 """arg3
52 docstring
53 """
54 '''
55 )
56 p = pytester.makepyfile(
57 """
58 def test_arg2(arg2):
59 pass
60 def test_arg3(arg3):
61 pass
62 """
63 )
64 result = pytester.runpytest("--fixtures-per-test", p)
65 assert result.ret == 0
66
67 result.stdout.fnmatch_lines(
68 [
69 "*fixtures used by test_arg2*",
70 "*(test_fixtures_in_conftest.py:2)*",
71 "arg2 -- conftest.py:6",
72 " arg2 docstring",
73 "*fixtures used by test_arg3*",
74 "*(test_fixtures_in_conftest.py:4)*",
75 "arg1 -- conftest.py:3",
76 " arg1 docstring",
77 "arg2 -- conftest.py:6",
78 " arg2 docstring",
79 "arg3 -- conftest.py:9",
80 " arg3",
81 ]
82 )
83
84
85def test_should_show_fixtures_used_by_test(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
makeconftestMethod · 0.45
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected