@@ -248,17 +248,15 @@ def __str__(self) -> str:
248
248
pytest .Testdir = Testdir # type: ignore[attr-defined]
249
249
250
250
251
- class LegacyTestdirPlugin :
252
- @staticmethod
253
- @pytest .fixture
254
- def testdir (pytester : pytest .Pytester ) -> Testdir :
255
- """
256
- Identical to :fixture:`pytester`, and provides an instance whose methods return
257
- legacy ``LEGACY_PATH`` objects instead when applicable.
251
+ @pytest .fixture
252
+ def testdir (pytester : pytest .Pytester ) -> Testdir :
253
+ """
254
+ Identical to :fixture:`pytester`, and provides an instance whose methods return
255
+ legacy ``LEGACY_PATH`` objects instead when applicable.
258
256
259
- New code should avoid using :fixture:`testdir` in favor of :fixture:`pytester`.
260
- """
261
- return Testdir (pytester , _ispytest = True )
257
+ New code should avoid using :fixture:`testdir` in favor of :fixture:`pytester`.
258
+ """
259
+ return Testdir (pytester , _ispytest = True )
262
260
263
261
264
262
@final
@@ -287,31 +285,29 @@ def getbasetemp(self) -> LEGACY_PATH:
287
285
pytest .TempdirFactory = TempdirFactory # type: ignore[attr-defined]
288
286
289
287
290
- class LegacyTmpdirPlugin :
291
- @staticmethod
292
- @pytest .fixture (scope = "session" )
293
- def tmpdir_factory (request : pytest .FixtureRequest ) -> TempdirFactory :
294
- """Return a :class:`pytest.TempdirFactory` instance for the test session."""
295
- # Set dynamically by pytest_configure().
296
- return request .config ._tmpdirhandler # type: ignore
288
+ @pytest .fixture (scope = "session" )
289
+ def tmpdir_factory (request : pytest .FixtureRequest ) -> TempdirFactory :
290
+ """Return a :class:`pytest.TempdirFactory` instance for the test session."""
291
+ # Set dynamically by pytest_configure().
292
+ return request .config ._tmpdirhandler # type: ignore
297
293
298
- @staticmethod
299
- @pytest .fixture
300
- def tmpdir (tmp_path : Path ) -> LEGACY_PATH :
301
- """Return a temporary directory path object which is unique to each test
302
- function invocation, created as a sub directory of the base temporary
303
- directory.
304
294
305
- By default, a new base temporary directory is created each test session,
306
- and old bases are removed after 3 sessions, to aid in debugging. If
307
- ``--basetemp`` is used then it is cleared each session. See :ref:`base
308
- temporary directory`.
295
+ @pytest .fixture
296
+ def tmpdir (tmp_path : Path ) -> LEGACY_PATH :
297
+ """Return a temporary directory path object which is unique to each test
298
+ function invocation, created as a sub directory of the base temporary
299
+ directory.
309
300
310
- The returned object is a `legacy_path`_ object.
301
+ By default, a new base temporary directory is created each test session,
302
+ and old bases are removed after 3 sessions, to aid in debugging. If
303
+ ``--basetemp`` is used then it is cleared each session. See :ref:`base
304
+ temporary directory`.
311
305
312
- .. _legacy_path: https://py.readthedocs.io/en/latest/path.html
313
- """
314
- return legacy_path (tmp_path )
306
+ The returned object is a `legacy_path`_ object.
307
+
308
+ .. _legacy_path: https://py.readthedocs.io/en/latest/path.html
309
+ """
310
+ return legacy_path (tmp_path )
315
311
316
312
317
313
def Cache_makedir (self : pytest .Cache , name : str ) -> LEGACY_PATH :
@@ -404,25 +400,19 @@ def pytest_configure(config: pytest.Config) -> None:
404
400
mp = pytest .MonkeyPatch ()
405
401
config .add_cleanup (mp .undo )
406
402
407
- if config .pluginmanager .has_plugin ("pytester" ):
408
- config .pluginmanager .register (LegacyTestdirPlugin , "legacypath-pytester" )
409
-
410
- if config .pluginmanager .has_plugin ("tmpdir" ):
411
- # Create TmpdirFactory and attach it to the config object.
412
- #
413
- # This is to comply with existing plugins which expect the handler to be
414
- # available at pytest_configure time, but ideally should be moved entirely
415
- # to the tmpdir_factory session fixture.
416
- try :
417
- tmp_path_factory = config ._tmp_path_factory # type: ignore[attr-defined]
418
- except AttributeError :
419
- # tmpdir plugin is blocked.
420
- pass
421
- else :
422
- _tmpdirhandler = TempdirFactory (tmp_path_factory , _ispytest = True )
423
- mp .setattr (config , "_tmpdirhandler" , _tmpdirhandler , raising = False )
424
-
425
- config .pluginmanager .register (LegacyTmpdirPlugin , "legacypath-tmpdir" )
403
+ # Create TmpdirFactory and attach it to the config object.
404
+ #
405
+ # This is to comply with existing plugins which expect the handler to be
406
+ # available at pytest_configure time, but ideally should be moved entirely
407
+ # to the tmpdir_factory session fixture.
408
+ try :
409
+ tmp_path_factory = config ._tmp_path_factory # type: ignore[attr-defined]
410
+ except AttributeError :
411
+ # tmpdir plugin is blocked.
412
+ pass
413
+ else :
414
+ _tmpdirhandler = TempdirFactory (tmp_path_factory , _ispytest = True )
415
+ mp .setattr (config , "_tmpdirhandler" , _tmpdirhandler , raising = False )
426
416
427
417
# Add Cache.makedir().
428
418
mp .setattr (pytest .Cache , "makedir" , Cache_makedir , raising = False )
0 commit comments