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
|
#!/usr/bin/env python3
# --------------------( LICENSE )--------------------
# Copyright (c) 2014-2025 Beartype authors.
# See "LICENSE" for further details.
'''
:mod:`pytest` **context manager utilities.**
'''
# ....................{ IMPORTS }....................
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# WARNING: To raise human-readable test errors, avoid importing from
# package-specific submodules at module scope.
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
from contextlib import (
AbstractContextManager,
contextmanager,
nullcontext,
)
# ....................{ CONTEXTS }....................
noop_context_manager = nullcontext
'''
**Noop context manager** (i.e., context manager trivially yielding the passed
parameter if any *or* :data:`None` otherwise).
Parameters
----------
enter_result : object, optional
Value to be yielded from this context manager. Defaults to :data:`None`.
Returns
-------
AbstractContextManager
Noop context manager.
'''
|