diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/python/pytest/py2/_pytest/recwarn.py | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/pytest/py2/_pytest/recwarn.py')
-rw-r--r-- | contrib/python/pytest/py2/_pytest/recwarn.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/contrib/python/pytest/py2/_pytest/recwarn.py b/contrib/python/pytest/py2/_pytest/recwarn.py index e5fa9c6a50..7abf2e9355 100644 --- a/contrib/python/pytest/py2/_pytest/recwarn.py +++ b/contrib/python/pytest/py2/_pytest/recwarn.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- """ recording warnings during test function execution. """ from __future__ import absolute_import from __future__ import division @@ -12,8 +12,8 @@ import warnings import six import _pytest._code -from _pytest.deprecated import PYTEST_WARNS_UNKNOWN_KWARGS -from _pytest.deprecated import WARNS_EXEC +from _pytest.deprecated import PYTEST_WARNS_UNKNOWN_KWARGS +from _pytest.deprecated import WARNS_EXEC from _pytest.fixtures import yield_fixture from _pytest.outcomes import fail @@ -87,26 +87,26 @@ def warns(expected_warning, *args, **kwargs): """ __tracebackhide__ = True if not args: - match_expr = kwargs.pop("match", None) - if kwargs: - warnings.warn( - PYTEST_WARNS_UNKNOWN_KWARGS.format(args=sorted(kwargs)), stacklevel=2 - ) + match_expr = kwargs.pop("match", None) + if kwargs: + warnings.warn( + PYTEST_WARNS_UNKNOWN_KWARGS.format(args=sorted(kwargs)), stacklevel=2 + ) return WarningsChecker(expected_warning, match_expr=match_expr) elif isinstance(args[0], str): - warnings.warn(WARNS_EXEC, stacklevel=2) - (code,) = args + warnings.warn(WARNS_EXEC, stacklevel=2) + (code,) = args assert isinstance(code, str) frame = sys._getframe(1) loc = frame.f_locals.copy() loc.update(kwargs) - with WarningsChecker(expected_warning): + with WarningsChecker(expected_warning): code = _pytest._code.Source(code).compile() - exec(code, frame.f_globals, loc) + exec(code, frame.f_globals, loc) else: func = args[0] - with WarningsChecker(expected_warning): + with WarningsChecker(expected_warning): return func(*args[1:], **kwargs) @@ -196,11 +196,11 @@ class WarningsRecorder(warnings.catch_warnings): warnings.warn = self._saved_warn super(WarningsRecorder, self).__exit__(*exc_info) - # Built-in catch_warnings does not reset entered state so we do it - # manually here for this context manager to become reusable. - self._entered = False + # Built-in catch_warnings does not reset entered state so we do it + # manually here for this context manager to become reusable. + self._entered = False + - class WarningsChecker(WarningsRecorder): def __init__(self, expected_warning=None, match_expr=None): super(WarningsChecker, self).__init__() |