test_ok2/doc/en/example/assertion/global_testmodule_config/conftest.py

15 lines
337 B
Python
Raw Normal View History

2020-07-27 08:56:06 +08:00
import os.path
2018-05-23 22:48:46 +08:00
import pytest
2020-07-27 08:56:06 +08:00
mydir = os.path.dirname(__file__)
2018-05-23 22:48:46 +08:00
def pytest_runtest_setup(item):
if isinstance(item, pytest.Function):
if not item.fspath.relto(mydir):
return
mod = item.getparent(pytest.Module).obj
2018-05-23 22:48:46 +08:00
if hasattr(mod, "hello"):
2018-08-23 09:30:42 +08:00
print("mod.hello {!r}".format(mod.hello))