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

Method test_autouse_fixture

testing/python/integration.py:45–79  ·  view source on GitHub ↗
(
        self, pytester: Pytester, recwarn
    )

Source from the content-addressed store, hash-verified

43 assert clscol.funcargs["arg1"] == 42
44
45 def test_autouse_fixture(
46 self, pytester: Pytester, recwarn
47 ) -> None: # rough jstests usage
48 pytester.makeconftest(
49 """
50 import pytest
51 def pytest_pycollect_makeitem(collector, name, obj):
52 if name == "MyClass":
53 return MyCollector.from_parent(collector, name=name)
54 class MyCollector(pytest.Collector):
55 def reportinfo(self):
56 return self.path, 3, "xyz"
57 """
58 )
59 modcol = pytester.getmodulecol(
60 """
61 import pytest
62 @pytest.fixture(autouse=True)
63 def hello():
64 pass
65 @pytest.fixture
66 def arg1(request):
67 return 42
68 class MyClass(object):
69 pass
70 """
71 )
72 # this hook finds funcarg factories
73 rep = runner.collect_one_node(modcol)
74 # TODO: Don't treat as Any.
75 clscol: Any = rep.result[0]
76 clscol.obj = lambda: None
77 clscol.funcargs = {}
78 pytest._fillfuncargs(clscol)
79 assert not clscol.funcargs
80
81
82def test_wrapped_getfslineno() -> None:

Callers

nothing calls this directly

Calls 2

makeconftestMethod · 0.45
getmodulecolMethod · 0.45

Tested by

no test coverage detected