|
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 |
@@ -114,35 +113,18 @@ def get_user() -> Optional[str]: |
114 | 113 | return None |
115 | 114 |
|
116 | 115 |
|
117 | | -def pytest_configure(config) -> None: |
118 | | - """Create a TempdirFactory and attach it to the config object. |
119 | | -
|
120 | | - This is to comply with existing plugins which expect the handler to be |
121 | | - available at pytest_configure time, but ideally should be moved entirely |
122 | | - to the tmpdir_factory session fixture. |
123 | | - """ |
124 | | - mp = MonkeyPatch() |
125 | | - tmppath_handler = TempPathFactory.from_config(config) |
126 | | - t = TempdirFactory(tmppath_handler) |
127 | | - config._cleanup.append(mp.undo) |
128 | | - mp.setattr(config, "_tmp_path_factory", tmppath_handler, raising=False) |
129 | | - mp.setattr(config, "_tmpdirhandler", t, raising=False) |
130 | | - |
131 | | - |
132 | 116 | @pytest.fixture(scope="session") |
133 | | -def tmpdir_factory(request: FixtureRequest) -> TempdirFactory: |
| 117 | +def tmpdir_factory(tmp_path_factory) -> TempdirFactory: |
134 | 118 | """Return a :class:`_pytest.tmpdir.TempdirFactory` instance for the test session. |
135 | 119 | """ |
136 | | - # Set dynamically by pytest_configure() above. |
137 | | - return request.config._tmpdirhandler # type: ignore |
| 120 | + return TempdirFactory(tmp_path_factory) |
138 | 121 |
|
139 | 122 |
|
140 | 123 | @pytest.fixture(scope="session") |
141 | 124 | def tmp_path_factory(request: FixtureRequest) -> TempPathFactory: |
142 | 125 | """Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session. |
143 | 126 | """ |
144 | | - # Set dynamically by pytest_configure() above. |
145 | | - return request.config._tmp_path_factory # type: ignore |
| 127 | + return TempPathFactory.from_config(request.config) |
146 | 128 |
|
147 | 129 |
|
148 | 130 | def _mk_tmp(request: FixtureRequest, factory: TempPathFactory) -> Path: |
|
0 commit comments