Merge pull request #6465 from blueyed/doc-rootdir

doc: revisit section about rootdir
This commit is contained in:
Daniel Hahler 2020-01-16 21:55:12 +01:00 committed by GitHub
commit 5b0e255e85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -20,8 +20,6 @@ which were registered by installed plugins.
Initialization: determining rootdir and inifile Initialization: determining rootdir and inifile
----------------------------------------------- -----------------------------------------------
pytest determines a ``rootdir`` for each test run which depends on pytest determines a ``rootdir`` for each test run which depends on
the command line arguments (specified test files, paths) and on the command line arguments (specified test files, paths) and on
the existence of *ini-files*. The determined ``rootdir`` and *ini-file* are the existence of *ini-files*. The determined ``rootdir`` and *ini-file* are
@ -30,17 +28,17 @@ printed as part of the pytest header during startup.
Here's a summary what ``pytest`` uses ``rootdir`` for: Here's a summary what ``pytest`` uses ``rootdir`` for:
* Construct *nodeids* during collection; each test is assigned * Construct *nodeids* during collection; each test is assigned
a unique *nodeid* which is rooted at the ``rootdir`` and takes in account full path, a unique *nodeid* which is rooted at the ``rootdir`` and takes into account
class name, function name and parametrization (if any). the full path, class name, function name and parametrization (if any).
* Is used by plugins as a stable location to store project/test run specific information; * Is used by plugins as a stable location to store project/test run specific information;
for example, the internal :ref:`cache <cache>` plugin creates a ``.pytest_cache`` subdirectory for example, the internal :ref:`cache <cache>` plugin creates a ``.pytest_cache`` subdirectory
in ``rootdir`` to store its cross-test run state. in ``rootdir`` to store its cross-test run state.
Important to emphasize that ``rootdir`` is **NOT** used to modify ``sys.path``/``PYTHONPATH`` or ``rootdir`` is **NOT** used to modify ``sys.path``/``PYTHONPATH`` or
influence how modules are imported. See :ref:`pythonpath` for more details. influence how modules are imported. See :ref:`pythonpath` for more details.
``--rootdir=path`` command-line option can be used to force a specific directory. The ``--rootdir=path`` command-line option can be used to force a specific directory.
The directory passed may contain environment variables when it is used in conjunction The directory passed may contain environment variables when it is used in conjunction
with ``addopts`` in a ``pytest.ini`` file. with ``addopts`` in a ``pytest.ini`` file.