Skip to content
Merged
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
18 changes: 4 additions & 14 deletions doc/en/example/markers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,11 @@ Registering markers

Registering markers for your test suite is simple:

.. tab:: toml
.. code-block:: toml

.. code-block:: toml

[pytest]
markers = ["webtest: mark a test as a webtest.", "slow: mark test as slow."]

.. tab:: ini

.. code-block:: ini

[pytest]
markers =
webtest: mark a test as a webtest.
slow: mark test as slow.
# content of pytest.toml
[pytest]
markers = ["webtest: mark a test as a webtest.", "slow: mark test as slow."]

Multiple custom markers can be registered, by defining each one in its own line, as shown in above example.

Expand Down
92 changes: 24 additions & 68 deletions doc/en/example/pythoncollection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,11 @@ Changing directory recursion

You can set the :confval:`norecursedirs` option in a configuration file:

.. tab:: toml
.. code-block:: toml

.. code-block:: toml

[pytest]
norecursedirs = [".svn", "_build", "tmp*"]

.. tab:: ini

.. code-block:: ini

[pytest]
norecursedirs = .svn _build tmp*
# content of pytest.toml
[pytest]
norecursedirs = [".svn", "_build", "tmp*"]

This would tell ``pytest`` to not recurse into typical subversion or sphinx-build directories or into any ``tmp`` prefixed directory.

Expand All @@ -116,25 +108,14 @@ the :confval:`python_files`, :confval:`python_classes` and
:confval:`python_functions` in your :ref:`configuration file <config file formats>`.
Here is an example:

.. tab:: toml

.. code-block:: toml
.. code-block:: toml

# Example 1: have pytest look for "check" instead of "test"
[pytest]
python_files = ["check_*.py"]
python_classes = ["Check"]
python_functions = ["*_check"]

.. tab:: ini

.. code-block:: ini

# Example 1: have pytest look for "check" instead of "test"
[pytest]
python_files = check_*.py
python_classes = Check
python_functions = *_check
# content of pytest.toml
# Example 1: have pytest look for "check" instead of "test"
[pytest]
python_files = ["check_*.py"]
python_classes = ["Check"]
python_functions = ["*_check"]

This would make ``pytest`` look for tests in files that match the ``check_*
.py`` glob-pattern, ``Check`` prefixes in classes, and functions and methods
Expand Down Expand Up @@ -171,21 +152,12 @@ The test collection would look like this:

You can check for multiple glob patterns by adding a space between the patterns:

.. tab:: toml

.. code-block:: toml

# Example 2: have pytest look for files with "test" and "example"
[pytest]
python_files = ["test_*.py", "example_*.py"]
.. code-block:: toml

.. tab:: ini

.. code-block:: ini

# Example 2: have pytest look for files with "test" and "example"
[pytest]
python_files = test_*.py example_*.py
# content of pytest.toml
# Example 2: have pytest look for files with "test" and "example"
[pytest]
python_files = ["test_*.py", "example_*.py"]

.. note::

Expand All @@ -209,19 +181,11 @@ which would run the respective test module. Like with
other options, through a configuration file and the :confval:`addopts` option you
can make this change more permanently:

.. tab:: toml

.. code-block:: toml

[pytest]
addopts = ["--pyargs"]

.. tab:: ini
.. code-block:: toml

.. code-block:: ini

[pytest]
addopts = --pyargs
# content of pytest.toml
[pytest]
addopts = ["--pyargs"]

Now a simple invocation of ``pytest NAME`` will check
if NAME exists as an importable package/module and otherwise
Expand Down Expand Up @@ -260,19 +224,11 @@ Customizing test collection

You can easily instruct ``pytest`` to discover tests from every Python file:

.. tab:: toml

.. code-block:: toml

[pytest]
python_files = ["*.py"]

.. tab:: ini

.. code-block:: ini
.. code-block:: toml

[pytest]
python_files = *.py
# content of pytest.toml
[pytest]
python_files = ["*.py"]

However, many projects will have a ``setup.py`` which they don't want to be
imported. Moreover, there may files only importable by a specific python
Expand Down
17 changes: 4 additions & 13 deletions doc/en/example/simple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ every time you use ``pytest``. For example, if you always want to see
detailed info on skipped and xfailed tests, as well as have terser "dot"
progress output, you can write it into a configuration file:

.. tab:: toml

.. code-block:: toml

[pytest]
addopts = ["-ra", "-q"]

.. tab:: ini

.. code-block:: ini

[pytest]
addopts = -ra -q
.. code-block:: toml

# content of pytest.toml
[pytest]
addopts = ["-ra", "-q"]

Alternatively, you can set a ``PYTEST_ADDOPTS`` environment variable to add command
line options while the environment is in use:
Expand Down
16 changes: 4 additions & 12 deletions doc/en/explanation/goodpractices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,11 @@ For new projects, we recommend to use ``importlib`` :ref:`import mode <import-mo
(see which-import-mode_ for a detailed explanation).
To this end, add the following to your configuration file:

.. tab:: toml

.. code-block:: toml

[pytest]
addopts = ["--import-mode=importlib"]

.. tab:: ini

.. code-block:: ini
.. code-block:: toml

[pytest]
addopts = --import-mode=importlib
# content of pytest.toml
[pytest]
addopts = ["--import-mode=importlib"]

.. _src-layout:

Expand Down
17 changes: 4 additions & 13 deletions doc/en/how-to/doctest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,11 @@ and functions, including from test modules:
You can make these changes permanent in your project by
putting them into a configuration file like this:

.. tab:: toml

.. code-block:: toml

[pytest]
addopts = ["--doctest-modules"]

.. tab:: ini

.. code-block:: ini

[pytest]
addopts = --doctest-modules
.. code-block:: toml

# content of pytest.toml
[pytest]
addopts = ["--doctest-modules"]

Encoding
--------
Expand Down
17 changes: 4 additions & 13 deletions doc/en/how-to/fixtures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1738,20 +1738,11 @@ and you may specify fixture usage at the test module level using :globalvar:`pyt
It is also possible to put fixtures required by all tests in your project
into a configuration file:

.. tab:: toml

.. code-block:: toml

[pytest]
usefixtures = ["cleandir"]

.. tab:: ini

.. code-block:: ini

[pytest]
usefixtures = cleandir
.. code-block:: toml

# content of pytest.toml
[pytest]
usefixtures = ["cleandir"]

.. warning::

Expand Down
16 changes: 4 additions & 12 deletions doc/en/how-to/writing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -422,19 +422,11 @@ which is especially useful for longer tests and/or longer ``conftest.py`` files.
Note that for ``pytester.copy_example`` to work we need to set `pytester_example_dir`
in our configuration file to tell pytest where to look for example files.

.. tab:: toml
.. code-block:: toml

.. code-block:: toml

[pytest]
pytester_example_dir = "."

.. tab:: ini

.. code-block:: ini

[pytest]
pytester_example_dir = .
# content of pytest.toml
[pytest]
pytester_example_dir = "."


.. code-block:: python
Expand Down
16 changes: 4 additions & 12 deletions doc/en/reference/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1333,19 +1333,11 @@ passed multiple times. The expected format is ``name=value``. For example::
Add the specified ``OPTS`` to the set of command line arguments as if they
had been specified by the user. Example: if you have this configuration file content:

.. tab:: toml

.. code-block:: toml

[pytest]
addopts = ["--maxfail=2", "-rf"] # exit after 2 failures, report fail info
.. code-block:: toml

.. tab:: ini

.. code-block:: ini

[pytest]
addopts = --maxfail=2 -rf # exit after 2 failures, report fail info
# content of pytest.toml
[pytest]
addopts = ["--maxfail=2", "-rf"] # exit after 2 failures, report fail info

issuing ``pytest test_hello.py`` actually means:

Expand Down