(pytester: Pytester)
| 163 | |
| 164 | |
| 165 | def test_conftest_global_import(pytester: Pytester) -> None: |
| 166 | pytester.makeconftest("x=3") |
| 167 | p = pytester.makepyfile( |
| 168 | """ |
| 169 | from pathlib import Path |
| 170 | import pytest |
| 171 | from _pytest.config import PytestPluginManager |
| 172 | conf = PytestPluginManager() |
| 173 | mod = conf._importconftest( |
| 174 | Path("conftest.py"), |
| 175 | importmode="prepend", |
| 176 | rootpath=Path.cwd(), |
| 177 | consider_namespace_packages=False, |
| 178 | ) |
| 179 | assert mod.x == 3 |
| 180 | import conftest |
| 181 | assert conftest is mod, (conftest, mod) |
| 182 | sub = Path("sub") |
| 183 | sub.mkdir() |
| 184 | subconf = sub / "conftest.py" |
| 185 | subconf.write_text("y=4", encoding="utf-8") |
| 186 | mod2 = conf._importconftest( |
| 187 | subconf, |
| 188 | importmode="prepend", |
| 189 | rootpath=Path.cwd(), |
| 190 | consider_namespace_packages=False, |
| 191 | ) |
| 192 | assert mod != mod2 |
| 193 | assert mod2.y == 4 |
| 194 | import conftest |
| 195 | assert conftest is mod2, (conftest, mod) |
| 196 | """ |
| 197 | ) |
| 198 | res = pytester.runpython(p) |
| 199 | assert res.ret == 0 |
| 200 | |
| 201 | |
| 202 | def test_conftestcutdir(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected