doc/en/example/assertion/global_testmodule_config/conftest.py
raw| 1 | from __future__ import annotations |
| 2 | |
| 3 | import os.path |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | |
| 8 | mydir = os.path.dirname(__file__) |
| 9 | |
| 10 | |
| 11 | def pytest_runtest_setup(item): |
| 12 | if isinstance(item, pytest.Function): |
| 13 | if not item.fspath.relto(mydir): |
| 14 | return |
| 15 | mod = item.getparent(pytest.Module).obj |
| 16 | if hasattr(mod, "hello"): |
| 17 | print(f"mod.hello {mod.hello!r}") |