Improve documentation of functionality

This commit is contained in:
Patrick Lannigan 2023-11-05 14:51:46 -05:00
parent cfb1654b65
commit 4d7ceb8d9f
No known key found for this signature in database
GPG Key ID: BBF5D9DED1E4AAF9
4 changed files with 38 additions and 5 deletions

View File

@ -1 +1,4 @@
:confval:`verbosity_assertions` option added to be able to control assertion output independent of the application wide verbosity level. Added fine-grained verbosity support to override the application wide verbosity level.
:class:`pytest.OutputVerbosity` can be used to retrieve the verbosity level for a specific :class:`pytest.VerbosityType`.
:confval:`verbosity_assertions` option added to be able to control assertion output independent of the application wide
verbosity level. See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>`.

View File

@ -270,17 +270,20 @@ situations, for example you are shown even fixtures that start with ``_`` if you
Using higher verbosity levels (``-vvv``, ``-vvvv``, ...) is supported, but has no effect in pytest itself at the moment, Using higher verbosity levels (``-vvv``, ``-vvvv``, ...) is supported, but has no effect in pytest itself at the moment,
however some plugins might make use of higher verbosity. however some plugins might make use of higher verbosity.
.. _`pytest.fine_grained_verbosity`:
Fine-grained verbosity Fine-grained verbosity
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In addition to specifying the application wide verbosity level, it is possible to control specific aspects independently. In addition to specifying the application wide verbosity level, it is possible to control specific aspects independently.
This is done by setting a verbosity level in the configuration file for the specific aspect of the output. This is done by setting a verbosity level in the configuration file for the specific aspect of the output.
:confval:`verbosity_assertions`: Controls how verbose the assertion output should be when pytest is executed. A value of ``2`` :confval:`verbosity_assertions`: Controls how verbose the assertion output should be when pytest is executed. Running
would have the same output as the previous example, but each test inside the file is shown by a single character in the ``pytest --no-header`` with a value of ``2`` would have the same output as the previous example, but each test inside
output. the file is shown by a single character in the output.
(Note: currently this is the only option available, but more might be added in the future). (Note: currently this is the only option available, but more might be added in the future).
.. _`pytest.detailed_failed_tests_usage`: .. _`pytest.detailed_failed_tests_usage`:
Producing a detailed summary report Producing a detailed summary report

View File

@ -957,6 +957,15 @@ OptionGroup
.. autoclass:: pytest.OptionGroup() .. autoclass:: pytest.OptionGroup()
:members: :members:
OutputVerbosity
~~~~~~~~~~~~~~~
.. autoclass:: pytest.OutputVerbosity()
:members:
.. autoclass:: pytest.VerbosityType()
:members:
PytestPluginManager PytestPluginManager
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -996,7 +1005,6 @@ Stash
:show-inheritance: :show-inheritance:
:members: :members:
Global Variables Global Variables
---------------- ----------------

View File

@ -1667,11 +1667,30 @@ class Config:
class VerbosityType(Enum): class VerbosityType(Enum):
"""Fine-grained verbosity categories.""" """Fine-grained verbosity categories."""
#: Application wide (default)
Global = "global" Global = "global"
Assertions = "assertions" Assertions = "assertions"
class OutputVerbosity: class OutputVerbosity:
r"""Access to fine-grained verbosity levels.
.. code-block:: ini
# content of pytest.ini
[pytest]
verbosity_assertions = 2
.. code-block:: bash
pytest -v
.. code-block:: python
print(config.output_verbosity.get()) # 1
print(config.output_verbosity.get(VerbosityType.Assertions)) # 2
"""
DEFAULT = "auto" DEFAULT = "auto"
_option_name_fmt = "verbosity_{}" _option_name_fmt = "verbosity_{}"