Skip to content
Open
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
1 change: 1 addition & 0 deletions changelog/11502.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``rootdir`` is no longer derived from a configuration file that is not a regular file, such as ``--config-file=/dev/null``.
1 change: 1 addition & 0 deletions changelog/13246.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The directory of a configuration file passed via :option:`-c` no longer determines the ``rootdir`` on its own: the ``rootdir`` is now the common ancestor of that directory and the collected test paths, falling back to the invocation directory when no paths are given. Keeping the configuration in a subdirectory -- the common ``-c config/pytest.ini`` layout -- previously moved the ``rootdir`` into that subdirectory, which broke ``conftest.py`` discovery and node IDs.
1 change: 1 addition & 0 deletions changelog/14705.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TOML configuration files passed via :option:`-c` now also read their configuration from the ``[pytest]`` table, the one pytest's own configuration files use. The ``[tool.pytest]`` and ``[tool.pytest.ini_options]`` tables such files were previously restricted to keep working; using both styles in one file is an error.
1 change: 1 addition & 0 deletions changelog/14716.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:option:`-c` now raises a usage error for a path that does not exist, is a directory, or is in a format pytest has no loader for. Such paths were previously either ignored or reported as an unhandled ``FileNotFoundError``.
1 change: 1 addition & 0 deletions changelog/9703.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The directory of a configuration file passed via :option:`-c` no longer determines the ``rootdir`` on its own: the ``rootdir`` is now the common ancestor of that directory and the collected test paths, falling back to the invocation directory when no paths are given. Keeping the configuration in a subdirectory -- the common ``-c config/pytest.ini`` layout -- previously moved the ``rootdir`` into that subdirectory, which broke ``conftest.py`` discovery and node IDs.
10 changes: 9 additions & 1 deletion doc/en/reference/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,15 @@ Finding the ``rootdir``

Here is the algorithm which finds the rootdir from ``args``:

- If :option:`-c` is passed in the command-line, use that as configuration file, and its directory as ``rootdir``.
- If :option:`-c` is passed in the command-line, use that as configuration file, and the common ancestor
of its directory and the ``args`` that are recognised as existing paths as ``rootdir``. When no such
paths are given, the directory pytest was invoked from takes their place; when the configuration file
and the paths share no ancestor other than the root of the file system, the configuration file's
directory is used.

.. versionchanged:: 10.0
The configuration file's directory used to become the ``rootdir`` on its own, which moved the
``rootdir`` into e.g. ``config/`` for the common ``-c config/pytest.ini`` layout.

- Determine the common ancestor directory for the specified ``args`` that are
recognised as paths that exist in the file system. If no such paths are
Expand Down
Loading