MCPcopy
hub / github.com/pytest-dev/pytest / setup

Method setup

src/_pytest/python.py:677–693  ·  src/_pytest/python.py::Package.setup
(self)

Source from the content-addressed store, hash-verified

675 )
676
677 def setup(self) -> None:
678 init_mod = importtestmodule(self.path / class="st">"__init__.py", self.config)
679
680 class="cm"># Not using fixtures to call setup_module here because autouse fixtures
681 class="cm"># from packages are not called automatically (#4085).
682 setup_module = _get_first_non_fixture_func(
683 init_mod, (class="st">"setUpModule", class="st">"setup_module")
684 )
685 if setup_module is not None:
686 _call_with_optional_argument(setup_module, init_mod)
687
688 teardown_module = _get_first_non_fixture_func(
689 init_mod, (class="st">"tearDownModule", class="st">"teardown_module")
690 )
691 if teardown_module is not None:
692 func = partial(_call_with_optional_argument, teardown_module, init_mod)
693 self.addfinalizer(func)
694
695 def collect(self) -> Iterable[nodes.Item | nodes.Collector]:
696 class="cm"># Always collect __init__.py first.

Callers

nothing calls this directly

Calls 4

importtestmoduleFunction · 0.85
addfinalizerMethod · 0.45

Tested by

no test coverage detected