test_ok2/doc/test/config.txt

49 lines
1.4 KiB
Plaintext

Test configuration
========================
test options and values
-----------------------------
You can see all available command line options by running::
py.test -h
py.test will lookup values of options in this order:
* option value supplied at command line
* content of environment variable ``PYTEST_OPTION_NAME=...``
* ``name = ...`` setting in the nearest ``conftest.py`` file.
The name of an option usually is the one you find
in the longform of the option, i.e. the name
behind the ``--`` double-dash.
IOW, you can set default values for options per project, per
home-directoray, per shell session or per test-run.
.. _`basetemp`:
per-testrun temporary directories
-------------------------------------------
``py.test`` runs provide means to create per-test session
temporary (sub) directories through the config object.
You can create directories like this:
.. XXX use a more local example, just with "config"
.. sourcecode: python
import py
basetemp = py.test.config.ensuretemp()
basetemp_subdir = py.test.config.ensuretemp("subdir")
By default, ``py.test`` creates a ``pytest-NUMBER`` directory
and will keep around the directories of the last three
test runs. You can also set the base temporary directory
with the `--basetemp`` option. When distributing
tests on the same machine, ``py.test`` takes care to
pass around the basetemp directory such that all temporary
files land below the same basetemp directory.