Skip to content

Commit 70cac3d

Browse files
Wolfremium13nicoddemuskevin.hierro-extDaniSancas
authored
Explicit note that tmpdir fixture is discouraged in favour of tmp_path #9937 (#10138)
Co-authored-by: Bruno Oliveira <[email protected]> Co-authored-by: kevin.hierro-ext <[email protected]> Co-authored-by: Dani Sancas <[email protected]>
1 parent c1d1341 commit 70cac3d

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

AUTHORS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Damian Skrzypczak
8787
Daniel Grana
8888
Daniel Hahler
8989
Daniel Nuri
90+
Daniel Sánchez Castelló
9091
Daniel Wandschneider
9192
Daniele Procida
9293
Danielle Jenkins
@@ -190,6 +191,7 @@ Katerina Koukiou
190191
Keri Volans
191192
Kevin C
192193
Kevin Cox
194+
Kevin Hierro Carrasco
193195
Kevin J. Foley
194196
Kian Eliasi
195197
Kian-Meng Ang
@@ -328,6 +330,7 @@ Taneli Hukkinen
328330
Tanvi Mehta
329331
Tarcisio Fischer
330332
Tareq Alayan
333+
Tatiana Ovary
331334
Ted Xiao
332335
Terje Runde
333336
Thomas Grainger
@@ -346,6 +349,7 @@ Tyler Goodlet
346349
Tzu-ping Chung
347350
Vasily Kuznetsov
348351
Victor Maryama
352+
Victor Rodriguez
349353
Victor Uriarte
350354
Vidar T. Fauske
351355
Virgil Dupras

changelog/9937.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Explicit note that :fixture:`tmpdir` fixture is discouraged in favour of :fixture:`tmp_path`.

doc/en/how-to/tmp_path.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ The ``tmpdir`` and ``tmpdir_factory`` fixtures
104104

105105
The ``tmpdir`` and ``tmpdir_factory`` fixtures are similar to ``tmp_path``
106106
and ``tmp_path_factory``, but use/return legacy `py.path.local`_ objects
107-
rather than standard :class:`pathlib.Path` objects. These days, prefer to
108-
use ``tmp_path`` and ``tmp_path_factory``.
107+
rather than standard :class:`pathlib.Path` objects.
108+
109+
.. note::
110+
These days, it is preferred to use ``tmp_path`` and ``tmp_path_factory``.
109111

110112
See :fixture:`tmpdir <tmpdir>` :fixture:`tmpdir_factory <tmpdir_factory>`
111113
API for details.

src/_pytest/legacypath.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,14 @@ def testdir(pytester: Pytester) -> Testdir:
271271
@attr.s(init=False, auto_attribs=True)
272272
class TempdirFactory:
273273
"""Backward compatibility wrapper that implements :class:`py.path.local`
274-
for :class:`TempPathFactory`."""
274+
for :class:`TempPathFactory`.
275+
276+
.. note::
277+
These days, it is preferred to use ``tmp_path_factory``.
278+
279+
:ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.
280+
281+
"""
275282

276283
_tmppath_factory: TempPathFactory
277284

@@ -312,6 +319,11 @@ def tmpdir(tmp_path: Path) -> LEGACY_PATH:
312319
313320
The returned object is a `legacy_path`_ object.
314321
322+
.. note::
323+
These days, it is preferred to use ``tmp_path``.
324+
325+
:ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.
326+
315327
.. _legacy_path: https://py.readthedocs.io/en/latest/path.html
316328
"""
317329
return legacy_path(tmp_path)

0 commit comments

Comments
 (0)