From 5d2183daf013588a0db5d46da43b31dfabecd3b4 Mon Sep 17 00:00:00 2001
From: Patrick Lannigan
Date: Mon, 13 Nov 2023 08:07:52 -0500
Subject: [PATCH] Improve documentation of get_verbosity() and configuraiton
---
doc/en/reference/reference.rst | 4 ++--
src/_pytest/config/__init__.py | 17 +++++++++++++++--
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst
index 180a70eed..22e5ee352 100644
--- a/doc/en/reference/reference.rst
+++ b/doc/en/reference/reference.rst
@@ -1826,13 +1826,13 @@ passed multiple times. The expected format is ``name=value``. For example::
Set a verbosity level specifically for assertion related output, overriding the application wide level.
-
.. code-block:: ini
[pytest]
verbosity_assertions = 2
- Defaults to application wide verbosity level (via the ``-v`` command-line option).
+ Defaults to application wide verbosity level (via the ``-v`` command-line option). A special value of
+ "auto" can be used to explicitly use the global verbosity level.
.. confval:: xfail_strict
diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py
index 414f78cf7..8c50040a7 100644
--- a/src/_pytest/config/__init__.py
+++ b/src/_pytest/config/__init__.py
@@ -1651,13 +1651,26 @@ class Config:
"""Deprecated, use getoption(skip=True) instead."""
return self.getoption(name, skip=True)
- #: Verbosity for failed assertions (see :confval:`verbosity_assertions`).
+ #: Verbosity type for failed assertions (see :confval:`verbosity_assertions`).
VERBOSITY_ASSERTIONS: Final = "assertions"
_KNOWN_VERBOSITY_TYPES: Final = {VERBOSITY_ASSERTIONS}
_VERBOSITY_INI_DEFAULT = "auto"
def get_verbosity(self, verbosity_type: Optional[str] = None) -> int:
- r"""Access to fine-grained verbosity levels.
+ r"""Retrieve the verbosity level for a fine-grained verbosity type.
+
+ :param verbosity_type: Verbosity type to get level for. If a level is
+ configured for the given type, that value will be returned. If the
+ given type is not a known verbosity type, the global verbosity
+ level will be returned. If the given type is None (default), the
+ global verbosity level will be returned.
+
+ To configure a level for a fine-grained verbosity type, the
+ configuration file should have a setting for the configuration name
+ and a numeric value for the verbosity level. A special value of "auto"
+ can be used to explicitly use the global verbosity level.
+
+ Example:
.. code-block:: ini