aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py3/_pytest/nose.py
diff options
context:
space:
mode:
authordeshevoy <deshevoy@yandex-team.ru>2022-02-10 16:46:57 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:57 +0300
commit28148f76dbfcc644d96427d41c92f36cbf2fdc6e (patch)
treeb83306b6e37edeea782e9eed673d89286c4fef35 /contrib/python/pytest/py3/_pytest/nose.py
parente988f30484abe5fdeedcc7a5d3c226c01a21800c (diff)
downloadydb-28148f76dbfcc644d96427d41c92f36cbf2fdc6e.tar.gz
Restoring authorship annotation for <deshevoy@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/pytest/py3/_pytest/nose.py')
-rw-r--r--contrib/python/pytest/py3/_pytest/nose.py62
1 files changed, 31 insertions, 31 deletions
diff --git a/contrib/python/pytest/py3/_pytest/nose.py b/contrib/python/pytest/py3/_pytest/nose.py
index 684c331272..bb8f99772a 100644
--- a/contrib/python/pytest/py3/_pytest/nose.py
+++ b/contrib/python/pytest/py3/_pytest/nose.py
@@ -1,39 +1,39 @@
"""Run testsuites written for nose."""
-from _pytest import python
-from _pytest import unittest
-from _pytest.config import hookimpl
+from _pytest import python
+from _pytest import unittest
+from _pytest.config import hookimpl
from _pytest.nodes import Item
-
-
-@hookimpl(trylast=True)
-def pytest_runtest_setup(item):
- if is_potential_nosetest(item):
- if not call_optional(item.obj, "setup"):
+
+
+@hookimpl(trylast=True)
+def pytest_runtest_setup(item):
+ if is_potential_nosetest(item):
+ if not call_optional(item.obj, "setup"):
# Call module level setup if there is no object level one.
- call_optional(item.parent.obj, "setup")
+ call_optional(item.parent.obj, "setup")
# XXX This implies we only call teardown when setup worked.
- item.session._setupstate.addfinalizer((lambda: teardown_nose(item)), item)
-
-
-def teardown_nose(item):
- if is_potential_nosetest(item):
- if not call_optional(item.obj, "teardown"):
- call_optional(item.parent.obj, "teardown")
-
-
+ item.session._setupstate.addfinalizer((lambda: teardown_nose(item)), item)
+
+
+def teardown_nose(item):
+ if is_potential_nosetest(item):
+ if not call_optional(item.obj, "teardown"):
+ call_optional(item.parent.obj, "teardown")
+
+
def is_potential_nosetest(item: Item) -> bool:
# Extra check needed since we do not do nose style setup/teardown
# on direct unittest style classes.
- return isinstance(item, python.Function) and not isinstance(
- item, unittest.TestCaseFunction
- )
-
-
-def call_optional(obj, name):
- method = getattr(obj, name, None)
- isfixture = hasattr(method, "_pytestfixturefunction")
- if method is not None and not isfixture and callable(method):
- # If there's any problems allow the exception to raise rather than
+ return isinstance(item, python.Function) and not isinstance(
+ item, unittest.TestCaseFunction
+ )
+
+
+def call_optional(obj, name):
+ method = getattr(obj, name, None)
+ isfixture = hasattr(method, "_pytestfixturefunction")
+ if method is not None and not isfixture and callable(method):
+ # If there's any problems allow the exception to raise rather than
# silently ignoring them.
- method()
- return True
+ method()
+ return True