aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py2/_pytest/unittest.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/python/pytest/py2/_pytest/unittest.py
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/pytest/py2/_pytest/unittest.py')
-rw-r--r--contrib/python/pytest/py2/_pytest/unittest.py110
1 files changed, 55 insertions, 55 deletions
diff --git a/contrib/python/pytest/py2/_pytest/unittest.py b/contrib/python/pytest/py2/_pytest/unittest.py
index 8445a6785c..3ff6f45d8d 100644
--- a/contrib/python/pytest/py2/_pytest/unittest.py
+++ b/contrib/python/pytest/py2/_pytest/unittest.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
""" discovery and running of std-library "unittest" style tests. """
from __future__ import absolute_import
from __future__ import division
@@ -8,7 +8,7 @@ import sys
import traceback
import _pytest._code
-import pytest
+import pytest
from _pytest.compat import getimfunc
from _pytest.config import hookimpl
from _pytest.outcomes import fail
@@ -40,12 +40,12 @@ class UnitTestCase(Class):
cls = self.obj
if not getattr(cls, "__test__", True):
return
-
- skipped = getattr(cls, "__unittest_skip__", False)
- if not skipped:
- self._inject_setup_teardown_fixtures(cls)
- self._inject_setup_class_fixture()
-
+
+ skipped = getattr(cls, "__unittest_skip__", False)
+ if not skipped:
+ self._inject_setup_teardown_fixtures(cls)
+ self._inject_setup_class_fixture()
+
self.session._fixturemanager.parsefactories(self, unittest=True)
loader = TestLoader()
foundsomething = False
@@ -64,48 +64,48 @@ class UnitTestCase(Class):
if ut is None or runtest != ut.TestCase.runTest:
yield TestCaseFunction("runTest", parent=self)
- def _inject_setup_teardown_fixtures(self, cls):
- """Injects a hidden auto-use fixture to invoke setUpClass/setup_method and corresponding
- teardown functions (#517)"""
- class_fixture = _make_xunit_fixture(
- cls, "setUpClass", "tearDownClass", scope="class", pass_self=False
- )
- if class_fixture:
- cls.__pytest_class_setup = class_fixture
-
- method_fixture = _make_xunit_fixture(
- cls, "setup_method", "teardown_method", scope="function", pass_self=True
- )
- if method_fixture:
- cls.__pytest_method_setup = method_fixture
-
-
-def _make_xunit_fixture(obj, setup_name, teardown_name, scope, pass_self):
- setup = getattr(obj, setup_name, None)
- teardown = getattr(obj, teardown_name, None)
- if setup is None and teardown is None:
- return None
-
- @pytest.fixture(scope=scope, autouse=True)
- def fixture(self, request):
- if getattr(self, "__unittest_skip__", None):
- reason = self.__unittest_skip_why__
- pytest.skip(reason)
- if setup is not None:
- if pass_self:
- setup(self, request.function)
- else:
- setup()
- yield
- if teardown is not None:
- if pass_self:
- teardown(self, request.function)
- else:
- teardown()
-
- return fixture
-
-
+ def _inject_setup_teardown_fixtures(self, cls):
+ """Injects a hidden auto-use fixture to invoke setUpClass/setup_method and corresponding
+ teardown functions (#517)"""
+ class_fixture = _make_xunit_fixture(
+ cls, "setUpClass", "tearDownClass", scope="class", pass_self=False
+ )
+ if class_fixture:
+ cls.__pytest_class_setup = class_fixture
+
+ method_fixture = _make_xunit_fixture(
+ cls, "setup_method", "teardown_method", scope="function", pass_self=True
+ )
+ if method_fixture:
+ cls.__pytest_method_setup = method_fixture
+
+
+def _make_xunit_fixture(obj, setup_name, teardown_name, scope, pass_self):
+ setup = getattr(obj, setup_name, None)
+ teardown = getattr(obj, teardown_name, None)
+ if setup is None and teardown is None:
+ return None
+
+ @pytest.fixture(scope=scope, autouse=True)
+ def fixture(self, request):
+ if getattr(self, "__unittest_skip__", None):
+ reason = self.__unittest_skip_why__
+ pytest.skip(reason)
+ if setup is not None:
+ if pass_self:
+ setup(self, request.function)
+ else:
+ setup()
+ yield
+ if teardown is not None:
+ if pass_self:
+ teardown(self, request.function)
+ else:
+ teardown()
+
+ return fixture
+
+
class TestCaseFunction(Function):
nofuncargs = True
_excinfo = None
@@ -143,10 +143,10 @@ class TestCaseFunction(Function):
rawexcinfo = getattr(rawexcinfo, "_rawexcinfo", rawexcinfo)
try:
excinfo = _pytest._code.ExceptionInfo(rawexcinfo)
- # invoke the attributes to trigger storing the traceback
- # trial causes some issue there
- excinfo.value
- excinfo.traceback
+ # invoke the attributes to trigger storing the traceback
+ # trial causes some issue there
+ excinfo.value
+ excinfo.traceback
except TypeError:
try:
try:
@@ -168,7 +168,7 @@ class TestCaseFunction(Function):
except KeyboardInterrupt:
raise
except fail.Exception:
- excinfo = _pytest._code.ExceptionInfo.from_current()
+ excinfo = _pytest._code.ExceptionInfo.from_current()
self.__dict__.setdefault("_excinfo", []).append(excinfo)
def addError(self, testcase, rawexcinfo):