(
self, pytester: Pytester, monkeypatch: MonkeyPatch
)
| 43 | ) |
| 44 | |
| 45 | def test_import_prepend_append( |
| 46 | self, pytester: Pytester, monkeypatch: MonkeyPatch |
| 47 | ) -> None: |
| 48 | root1 = pytester.mkdir("root1") |
| 49 | root2 = pytester.mkdir("root2") |
| 50 | root1.joinpath("x456.py").touch() |
| 51 | root2.joinpath("x456.py").touch() |
| 52 | p = root2.joinpath("test_x456.py") |
| 53 | monkeypatch.syspath_prepend(str(root1)) |
| 54 | p.write_text( |
| 55 | textwrap.dedent( |
| 56 | """\ |
| 57 | import x456 |
| 58 | def test(): |
| 59 | assert x456.__file__.startswith({!r}) |
| 60 | """.format( |
| 61 | str(root2) |
| 62 | ) |
| 63 | ) |
| 64 | ) |
| 65 | with monkeypatch.context() as mp: |
| 66 | mp.chdir(root2) |
| 67 | reprec = pytester.inline_run("--import-mode=append") |
| 68 | reprec.assertoutcome(passed=0, failed=1) |
| 69 | reprec = pytester.inline_run() |
| 70 | reprec.assertoutcome(passed=1) |
| 71 | |
| 72 | def test_syntax_error_in_module(self, pytester: Pytester) -> None: |
| 73 | modcol = pytester.getmodulecol("this is a syntax error") |
nothing calls this directly
no test coverage detected