Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Damian Skrzypczak
Daniel Grana
Daniel Hahler
Daniel Nuri
Daniel Sánchez Castelló
Daniel Wandschneider
Daniele Procida
Danielle Jenkins
Expand Down Expand Up @@ -185,6 +186,7 @@ Katarzyna Król
Katerina Koukiou
Keri Volans
Kevin Cox
Kevin Hierro Carrasco
Kevin J. Foley
Kian Eliasi
Kian-Meng Ang
Expand Down Expand Up @@ -322,6 +324,7 @@ Taneli Hukkinen
Tanvi Mehta
Tarcisio Fischer
Tareq Alayan
Tatiana Ovary
Ted Xiao
Terje Runde
Thomas Grainger
Expand All @@ -339,6 +342,7 @@ Tyler Goodlet
Tzu-ping Chung
Vasily Kuznetsov
Victor Maryama
Victor Rodriguez
Victor Uriarte
Vidar T. Fauske
Virgil Dupras
Expand Down
1 change: 1 addition & 0 deletions changelog/9937.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Explicit note that :fixture:`tmpdir` fixture is discouraged in favour of :fixture:`tmp_path`.
6 changes: 4 additions & 2 deletions doc/en/how-to/tmp_path.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ The ``tmpdir`` and ``tmpdir_factory`` fixtures

The ``tmpdir`` and ``tmpdir_factory`` fixtures are similar to ``tmp_path``
and ``tmp_path_factory``, but use/return legacy `py.path.local`_ objects
rather than standard :class:`pathlib.Path` objects. These days, prefer to
use ``tmp_path`` and ``tmp_path_factory``.
rather than standard :class:`pathlib.Path` objects.

.. note::
These days, it is preferred to use ``tmp_path`` and ``tmp_path_factory``.

See :fixture:`tmpdir <tmpdir>` :fixture:`tmpdir_factory <tmpdir_factory>`
API for details.
Expand Down
14 changes: 13 additions & 1 deletion src/_pytest/legacypath.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,14 @@ def testdir(pytester: Pytester) -> Testdir:
@attr.s(init=False, auto_attribs=True)
class TempdirFactory:
"""Backward compatibility wrapper that implements :class:`py.path.local`
for :class:`TempPathFactory`."""
for :class:`TempPathFactory`.

.. note::
These days, it is preferred to use ``tmp_path_factory``.

:ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.

"""

_tmppath_factory: TempPathFactory

Expand Down Expand Up @@ -312,6 +319,11 @@ def tmpdir(tmp_path: Path) -> LEGACY_PATH:

The returned object is a `legacy_path`_ object.

.. note::
These days, it is preferred to use ``tmp_path``.

:ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.

.. _legacy_path: https://py.readthedocs.io/en/latest/path.html
"""
return legacy_path(tmp_path)
Expand Down
6 changes: 5 additions & 1 deletion testing/test_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ def test_doctest_unexpected_exception(self, pytester: Pytester):
"Traceback (most recent call last):",
' File "*/doctest.py", line *, in __run',
" *",
*((" *^^^^*",) if sys.version_info >= (3, 11) else ()),
*(
(" *^^^^*",)
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
else ()
),
' File "<doctest test_doctest_unexpected_exception.txt[1]>", line 1, in <module>',
"ZeroDivisionError: division by zero",
"*/test_doctest_unexpected_exception.txt:2: UnexpectedException",
Expand Down
6 changes: 3 additions & 3 deletions testing/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def pytest_internalerror(excrepr, excinfo):

end_lines = (
result.stdout.lines[-4:]
if sys.version_info >= (3, 11)
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
else result.stdout.lines[-3:]
)

Expand All @@ -57,7 +57,7 @@ def pytest_internalerror(excrepr, excinfo):
'INTERNALERROR> raise SystemExit("boom")',
*(
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
if sys.version_info >= (3, 11)
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
else ()
),
"INTERNALERROR> SystemExit: boom",
Expand All @@ -68,7 +68,7 @@ def pytest_internalerror(excrepr, excinfo):
'INTERNALERROR> raise ValueError("boom")',
*(
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
if sys.version_info >= (3, 11)
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
else ()
),
"INTERNALERROR> ValueError: boom",
Expand Down