|
14 | 14 | from .pathlib import make_numbered_dir_with_cleanup |
15 | 15 | from .pathlib import Path |
16 | 16 | from _pytest.fixtures import FixtureRequest |
17 | | -from _pytest.monkeypatch import MonkeyPatch |
18 | 17 |
|
19 | 18 |
|
20 | 19 | @attr.s |
@@ -135,35 +134,18 @@ def get_user() -> Optional[str]: |
135 | 134 | return None |
136 | 135 |
|
137 | 136 |
|
138 | | -def pytest_configure(config) -> None: |
139 | | - """Create a TempdirFactory and attach it to the config object. |
140 | | -
|
141 | | - This is to comply with existing plugins which expect the handler to be |
142 | | - available at pytest_configure time, but ideally should be moved entirely |
143 | | - to the tmpdir_factory session fixture. |
144 | | - """ |
145 | | - mp = MonkeyPatch() |
146 | | - tmppath_handler = TempPathFactory.from_config(config) |
147 | | - t = TempdirFactory(tmppath_handler) |
148 | | - config._cleanup.append(mp.undo) |
149 | | - mp.setattr(config, "_tmp_path_factory", tmppath_handler, raising=False) |
150 | | - mp.setattr(config, "_tmpdirhandler", t, raising=False) |
151 | | - |
152 | | - |
153 | 137 | @pytest.fixture(scope="session") |
154 | | -def tmpdir_factory(request: FixtureRequest) -> TempdirFactory: |
| 138 | +def tmpdir_factory(tmp_path_factory) -> TempdirFactory: |
155 | 139 | """Return a :class:`_pytest.tmpdir.TempdirFactory` instance for the test session. |
156 | 140 | """ |
157 | | - # Set dynamically by pytest_configure() above. |
158 | | - return request.config._tmpdirhandler # type: ignore |
| 141 | + return TempdirFactory(tmp_path_factory) |
159 | 142 |
|
160 | 143 |
|
161 | 144 | @pytest.fixture(scope="session") |
162 | 145 | def tmp_path_factory(request: FixtureRequest) -> TempPathFactory: |
163 | 146 | """Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session. |
164 | 147 | """ |
165 | | - # Set dynamically by pytest_configure() above. |
166 | | - return request.config._tmp_path_factory # type: ignore |
| 148 | + return TempPathFactory.from_config(request.config) |
167 | 149 |
|
168 | 150 |
|
169 | 151 | def _mk_tmp(request: FixtureRequest, factory: TempPathFactory) -> Path: |
|
0 commit comments