Expect the correct path to be set and the correct import and app names to be returned. :func:`prepare_exec_for_file` has a side effect where the parent directory of the given import is added to :data:`sys.path`. This is reset after the test runs.
(request, value, path, result)
| 159 | ), |
| 160 | ) |
| 161 | def test_prepare_import(request, value, path, result): |
| 162 | """Expect the correct path to be set and the correct import and app names |
| 163 | to be returned. |
| 164 | |
| 165 | :func:`prepare_exec_for_file` has a side effect where the parent directory |
| 166 | of the given import is added to :data:`sys.path`. This is reset after the |
| 167 | test runs. |
| 168 | """ |
| 169 | original_path = sys.path[:] |
| 170 | |
| 171 | def reset_path(): |
| 172 | sys.path[:] = original_path |
| 173 | |
| 174 | request.addfinalizer(reset_path) |
| 175 | |
| 176 | assert prepare_import(value) == result |
| 177 | assert sys.path[0] == str(path) |
| 178 | |
| 179 | |
| 180 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected