(pytester: Pytester)
| 1140 | |
| 1141 | |
| 1142 | def test_collect_with_chdir_during_import(pytester: Pytester) -> None: |
| 1143 | subdir = pytester.mkdir("sub") |
| 1144 | pytester.path.joinpath("conftest.py").write_text( |
| 1145 | textwrap.dedent( |
| 1146 | """ |
| 1147 | import os |
| 1148 | os.chdir(%r) |
| 1149 | """ |
| 1150 | % (str(subdir),) |
| 1151 | ) |
| 1152 | ) |
| 1153 | pytester.makepyfile( |
| 1154 | """ |
| 1155 | def test_1(): |
| 1156 | import os |
| 1157 | assert os.getcwd() == %r |
| 1158 | """ |
| 1159 | % (str(subdir),) |
| 1160 | ) |
| 1161 | with pytester.path.cwd(): |
| 1162 | result = pytester.runpytest() |
| 1163 | result.stdout.fnmatch_lines(["*1 passed in*"]) |
| 1164 | assert result.ret == 0 |
| 1165 | |
| 1166 | # Handles relative testpaths. |
| 1167 | pytester.makeini( |
| 1168 | """ |
| 1169 | [pytest] |
| 1170 | testpaths = . |
| 1171 | """ |
| 1172 | ) |
| 1173 | with pytester.path.cwd(): |
| 1174 | result = pytester.runpytest("--collect-only") |
| 1175 | result.stdout.fnmatch_lines(["collected 1 item"]) |
| 1176 | |
| 1177 | |
| 1178 | def test_collect_pyargs_with_testpaths( |
nothing calls this directly
no test coverage detected