Update documentation to describe expected rootdir behaviour

This commit is contained in:
Dave Hunt 2016-06-21 21:48:59 +02:00 committed by Daniel Hahler
parent a2891420de
commit eb08135280
1 changed files with 19 additions and 15 deletions

View File

@ -29,25 +29,29 @@ project/testrun-specific information.
Here is the algorithm which finds the rootdir from ``args``: Here is the algorithm which finds the rootdir from ``args``:
- determine the common ancestor directory for the specified ``args``. - 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
found, the common ancestor directory is set to the current working directory.
- look for ``pytest.ini``, ``tox.ini`` and ``setup.cfg`` files in the - look for ``pytest.ini``, ``tox.ini`` and ``setup.cfg`` files in the ancestor
ancestor directory and upwards. If one is matched, it becomes the directory and upwards. If one is matched, it becomes the ini-file and its
ini-file and its directory becomes the rootdir. An existing directory becomes the rootdir.
``pytest.ini`` file will always be considered a match whereas
``tox.ini`` and ``setup.cfg`` will only match if they contain
a ``[pytest]`` section.
- if no ini-file was found, look for ``setup.py`` upwards from - if no ini-file was found, look for ``setup.py`` upwards from the common
the common ancestor directory to determine the ``rootdir``. ancestor directory to determine the ``rootdir``.
- if no ini-file and no ``setup.py`` was found, use the already - if no ``setup.py`` was found, look for ``pytest.ini``, ``tox.ini`` and
determined common ancestor as root directory. This allows to ``setup.cfg`` in each of the specified ``args`` and upwards. If one is
work with pytest in structures that are not part of a package matched, it becomes the ini-file and its directory becomes the rootdir.
and don't have any particular ini-file configuration.
Note that options from multiple ini-files candidates are never merged, - if no ini-file was found, use the already determined common ancestor as root
the first one wins (``pytest.ini`` always wins even if it does not directory. This allows to work with pytest in structures that are not part of
a package and don't have any particular ini-file configuration.
Note that an existing ``pytest.ini`` file will always be considered a match,
whereas ``tox.ini`` and ``setup.cfg`` will only match if they contain a
``[pytest]`` section. Options from multiple ini-files candidates are never
merged - the first one wins (``pytest.ini`` always wins, even if it does not
contain a ``[pytest]`` section). contain a ``[pytest]`` section).
The ``config`` object will subsequently carry these attributes: The ``config`` object will subsequently carry these attributes: