Skip to content
Closed
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
3 changes: 3 additions & 0 deletions changelog/7425.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
New :fixture:`test_path` fixture, which is identical to :fixture:`testdir` but its methods return :class:`pathlib.Path` when appropriate instead of ``py.path.local``.

This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future.
27 changes: 20 additions & 7 deletions doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -494,25 +494,29 @@ monkeypatch
:members:


.. fixture:: testdir
.. fixture:: test_path

testdir
~~~~~~~
test_path
~~~~~~~~~

.. versionadded:: 6.0

.. currentmodule:: _pytest.pytester

This fixture provides a :class:`Testdir` instance useful for black-box testing of test files, making it ideal to
test plugins.
Provides a :class:`TestPath` instance that can be used to run and test pytest itself.

It provides an empty directory where pytest can be executed in isolation, and contains facilities
to write test, configuration files, and match against expected output.

To use it, include in your top-most ``conftest.py`` file:
To use it, include in your topmost ``conftest.py`` file:

.. code-block:: python

pytest_plugins = "pytester"



.. autoclass:: Testdir()
.. autoclass:: TestPath()
:members:

.. autoclass:: RunResult()
Expand All @@ -521,6 +525,15 @@ To use it, include in your top-most ``conftest.py`` file:
.. autoclass:: LineMatcher()
:members:

.. fixture:: testdir

testdir
~~~~~~~

Identical to :fixture:`test_path`, but provides an instance whose methods return
legacy ``py.path.local`` objects instead when applicable.

New code should avoid using :fixture:`testdir` in favor of :fixture:`test_path`.

.. fixture:: recwarn

Expand Down
Loading