Merge pull request #10140 from pytest-dev/backport-10138-to-7.1.x
[7.1.x] Explicit note that tmpdir fixture is discouraged in favour of tmp_path #9937
This commit is contained in:
commit
121b69276a
4
AUTHORS
4
AUTHORS
|
@ -84,6 +84,7 @@ Damian Skrzypczak
|
||||||
Daniel Grana
|
Daniel Grana
|
||||||
Daniel Hahler
|
Daniel Hahler
|
||||||
Daniel Nuri
|
Daniel Nuri
|
||||||
|
Daniel Sánchez Castelló
|
||||||
Daniel Wandschneider
|
Daniel Wandschneider
|
||||||
Daniele Procida
|
Daniele Procida
|
||||||
Danielle Jenkins
|
Danielle Jenkins
|
||||||
|
@ -185,6 +186,7 @@ Katarzyna Król
|
||||||
Katerina Koukiou
|
Katerina Koukiou
|
||||||
Keri Volans
|
Keri Volans
|
||||||
Kevin Cox
|
Kevin Cox
|
||||||
|
Kevin Hierro Carrasco
|
||||||
Kevin J. Foley
|
Kevin J. Foley
|
||||||
Kian Eliasi
|
Kian Eliasi
|
||||||
Kian-Meng Ang
|
Kian-Meng Ang
|
||||||
|
@ -322,6 +324,7 @@ Taneli Hukkinen
|
||||||
Tanvi Mehta
|
Tanvi Mehta
|
||||||
Tarcisio Fischer
|
Tarcisio Fischer
|
||||||
Tareq Alayan
|
Tareq Alayan
|
||||||
|
Tatiana Ovary
|
||||||
Ted Xiao
|
Ted Xiao
|
||||||
Terje Runde
|
Terje Runde
|
||||||
Thomas Grainger
|
Thomas Grainger
|
||||||
|
@ -339,6 +342,7 @@ Tyler Goodlet
|
||||||
Tzu-ping Chung
|
Tzu-ping Chung
|
||||||
Vasily Kuznetsov
|
Vasily Kuznetsov
|
||||||
Victor Maryama
|
Victor Maryama
|
||||||
|
Victor Rodriguez
|
||||||
Victor Uriarte
|
Victor Uriarte
|
||||||
Vidar T. Fauske
|
Vidar T. Fauske
|
||||||
Virgil Dupras
|
Virgil Dupras
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Explicit note that :fixture:`tmpdir` fixture is discouraged in favour of :fixture:`tmp_path`.
|
|
@ -104,8 +104,10 @@ The ``tmpdir`` and ``tmpdir_factory`` fixtures
|
||||||
|
|
||||||
The ``tmpdir`` and ``tmpdir_factory`` fixtures are similar to ``tmp_path``
|
The ``tmpdir`` and ``tmpdir_factory`` fixtures are similar to ``tmp_path``
|
||||||
and ``tmp_path_factory``, but use/return legacy `py.path.local`_ objects
|
and ``tmp_path_factory``, but use/return legacy `py.path.local`_ objects
|
||||||
rather than standard :class:`pathlib.Path` objects. These days, prefer to
|
rather than standard :class:`pathlib.Path` objects.
|
||||||
use ``tmp_path`` and ``tmp_path_factory``.
|
|
||||||
|
.. note::
|
||||||
|
These days, it is preferred to use ``tmp_path`` and ``tmp_path_factory``.
|
||||||
|
|
||||||
See :fixture:`tmpdir <tmpdir>` :fixture:`tmpdir_factory <tmpdir_factory>`
|
See :fixture:`tmpdir <tmpdir>` :fixture:`tmpdir_factory <tmpdir_factory>`
|
||||||
API for details.
|
API for details.
|
||||||
|
|
|
@ -271,7 +271,14 @@ class LegacyTestdirPlugin:
|
||||||
@attr.s(init=False, auto_attribs=True)
|
@attr.s(init=False, auto_attribs=True)
|
||||||
class TempdirFactory:
|
class TempdirFactory:
|
||||||
"""Backward compatibility wrapper that implements :class:`py.path.local`
|
"""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
|
_tmppath_factory: TempPathFactory
|
||||||
|
|
||||||
|
@ -312,6 +319,11 @@ class LegacyTmpdirPlugin:
|
||||||
|
|
||||||
The returned object is a `legacy_path`_ object.
|
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
|
.. _legacy_path: https://py.readthedocs.io/en/latest/path.html
|
||||||
"""
|
"""
|
||||||
return legacy_path(tmp_path)
|
return legacy_path(tmp_path)
|
||||||
|
|
|
@ -223,7 +223,11 @@ class TestDoctests:
|
||||||
"Traceback (most recent call last):",
|
"Traceback (most recent call last):",
|
||||||
' File "*/doctest.py", line *, in __run',
|
' 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>',
|
' File "<doctest test_doctest_unexpected_exception.txt[1]>", line 1, in <module>',
|
||||||
"ZeroDivisionError: division by zero",
|
"ZeroDivisionError: division by zero",
|
||||||
"*/test_doctest_unexpected_exception.txt:2: UnexpectedException",
|
"*/test_doctest_unexpected_exception.txt:2: UnexpectedException",
|
||||||
|
|
|
@ -47,7 +47,7 @@ def test_wrap_session_notify_exception(ret_exc, pytester: Pytester) -> None:
|
||||||
|
|
||||||
end_lines = (
|
end_lines = (
|
||||||
result.stdout.lines[-4:]
|
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:]
|
else result.stdout.lines[-3:]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ def test_wrap_session_notify_exception(ret_exc, pytester: Pytester) -> None:
|
||||||
'INTERNALERROR> raise SystemExit("boom")',
|
'INTERNALERROR> raise SystemExit("boom")',
|
||||||
*(
|
*(
|
||||||
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
|
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
|
||||||
if sys.version_info >= (3, 11)
|
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
|
||||||
else ()
|
else ()
|
||||||
),
|
),
|
||||||
"INTERNALERROR> SystemExit: boom",
|
"INTERNALERROR> SystemExit: boom",
|
||||||
|
@ -68,7 +68,7 @@ def test_wrap_session_notify_exception(ret_exc, pytester: Pytester) -> None:
|
||||||
'INTERNALERROR> raise ValueError("boom")',
|
'INTERNALERROR> raise ValueError("boom")',
|
||||||
*(
|
*(
|
||||||
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
|
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
|
||||||
if sys.version_info >= (3, 11)
|
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
|
||||||
else ()
|
else ()
|
||||||
),
|
),
|
||||||
"INTERNALERROR> ValueError: boom",
|
"INTERNALERROR> ValueError: boom",
|
||||||
|
|
Loading…
Reference in New Issue