1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
Configuration
=============
The ``pytest.ini`` configuration file allows you to set default values for the plugin's options,
enabling a consistent test execution environment without the need to specify :doc:`command-line options </cli>` every time.
Available ``pytest.ini`` Options
--------------------------------
Below are the ``pytest.ini`` options supported by the plugin:
``reruns``
^^^^^^^^^^
- **Description**: Sets the default number of times to rerun failed tests. If not set, you must provide the :option:`--reruns` option on the command line.
- **Type**: String
- **Default**: Not set (must be provided as a CLI argument if not configured).
- **Example**:
.. code-block:: ini
[pytest]
reruns = 3
``reruns_delay``
^^^^^^^^^^^^^^^^
- **Description**: Sets the default delay (in seconds) between reruns of failed tests.
- **Type**: String
- **Default**: Not set (optional).
- **Example**:
.. code-block:: ini
[pytest]
reruns_delay = 2.5
Example
-------
To configure your test environment for consistent retries and delays, add the following options to your ``pytest.ini`` file:
.. code-block:: ini
[pytest]
reruns = 3
reruns_delay = 2.0
This setup ensures that:
- Failed tests will be retried up to 3 times.
- There will be a 2-second delay between each retry.
Overriding ``pytest.ini`` Options
---------------------------------
Command-line arguments always override ``pytest.ini`` settings. For example:
.. code-block:: bash
pytest --reruns 5 --reruns-delay 1.5
This will retry tests 5 times with a 1.5-second delay, regardless of the values set in ``pytest.ini``.
|