Improve docs
This commit is contained in:
parent
d2529edef0
commit
c5cc08a861
|
@ -1,4 +1,5 @@
|
||||||
Added fine-grained verbosity support to override the application wide verbosity level.
|
Added the new :confval:`verbosity_assertions` configuration option for fine-grained control of failed assertions verbosity.
|
||||||
: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
|
See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>` for more details.
|
||||||
verbosity level. See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>`.
|
|
||||||
|
For plugin authors, :attr:`config.output_verbosity <pytest.Config.output_verbosity>` can be used to retrieve the verbosity level for a specific :class:`pytest.VerbosityType`.
|
||||||
|
|
|
@ -1841,7 +1841,7 @@ passed multiple times. The expected format is ``name=value``. For example::
|
||||||
[pytest]
|
[pytest]
|
||||||
verbosity_assertions = 2
|
verbosity_assertions = 2
|
||||||
|
|
||||||
Defaults to application wide verbosity level.
|
Defaults to application wide verbosity level (via the ``-v`` command-line option).
|
||||||
|
|
||||||
|
|
||||||
.. confval:: xfail_strict
|
.. confval:: xfail_strict
|
||||||
|
|
|
@ -1021,7 +1021,12 @@ class Config:
|
||||||
)
|
)
|
||||||
self.args_source = Config.ArgsSource.ARGS
|
self.args_source = Config.ArgsSource.ARGS
|
||||||
self.args: List[str] = []
|
self.args: List[str] = []
|
||||||
|
|
||||||
self.output_verbosity = OutputVerbosity(self)
|
self.output_verbosity = OutputVerbosity(self)
|
||||||
|
"""Access to output verbosity configuration.
|
||||||
|
|
||||||
|
:type: OutputVerbosity
|
||||||
|
"""
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from _pytest.cacheprovider import Cache
|
from _pytest.cacheprovider import Cache
|
||||||
|
@ -1667,21 +1672,25 @@ class Config:
|
||||||
class VerbosityType(Enum):
|
class VerbosityType(Enum):
|
||||||
"""Fine-grained verbosity categories."""
|
"""Fine-grained verbosity categories."""
|
||||||
|
|
||||||
#: Application wide (default)
|
#: Application wide, controlled by ``-v``/``-q``.
|
||||||
Global = "global"
|
Global = "global"
|
||||||
|
|
||||||
|
#: Verbosity for failed assertions (see :confval:`verbosity_assertions`).
|
||||||
Assertions = "assertions"
|
Assertions = "assertions"
|
||||||
|
|
||||||
|
|
||||||
class OutputVerbosity:
|
class OutputVerbosity:
|
||||||
r"""Access to fine-grained verbosity levels.
|
r"""Access to fine-grained verbosity levels.
|
||||||
|
|
||||||
|
Access via :attr:`config.output_verbosity <pytest.Config.output_verbosity>`.
|
||||||
|
|
||||||
.. code-block:: ini
|
.. code-block:: ini
|
||||||
|
|
||||||
# content of pytest.ini
|
# content of pytest.ini
|
||||||
[pytest]
|
[pytest]
|
||||||
verbosity_assertions = 2
|
verbosity_assertions = 2
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
pytest -v
|
pytest -v
|
||||||
|
|
||||||
|
@ -1699,7 +1708,11 @@ class OutputVerbosity:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def verbose(self) -> int:
|
def verbose(self) -> int:
|
||||||
"""Application wide verbosity level."""
|
"""
|
||||||
|
Application wide verbosity level.
|
||||||
|
|
||||||
|
Same as the traditional ``config.getoption("verbose")``.
|
||||||
|
"""
|
||||||
assert isinstance(self._config.option.verbose, int)
|
assert isinstance(self._config.option.verbose, int)
|
||||||
return self._config.option.verbose
|
return self._config.option.verbose
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue