summaryrefslogtreecommitdiff
path: root/src/_pytest/unittest.py
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2019-10-16 21:52:04 +0200
committerRonny Pfannschmidt <ronny.pfannschmidt@redhat.com>2019-11-23 21:54:11 +0100
commitc99c7d0f95170a5e308ed6c37e63b2d90794a4f9 (patch)
tree69f05b6ec107f6a979c3b2c037aa598e61da58d9 /src/_pytest/unittest.py
parent886b8d27c669c6a65488192f75299a7cb9e1ab52 (diff)
downloadpytest-c99c7d0f95170a5e308ed6c37e63b2d90794a4f9.tar.gz
deprecate direct node construction and introduce Node.from_parent
Diffstat (limited to 'src/_pytest/unittest.py')
-rw-r--r--src/_pytest/unittest.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py
index 11dc77cc4..1ddb9c867 100644
--- a/src/_pytest/unittest.py
+++ b/src/_pytest/unittest.py
@@ -23,7 +23,7 @@ def pytest_pycollect_makeitem(collector, name, obj):
except Exception:
return
# yes, so let's collect it
- return UnitTestCase(name, parent=collector)
+ return UnitTestCase.from_parent(collector, name=name, obj=obj)
class UnitTestCase(Class):
@@ -51,7 +51,7 @@ class UnitTestCase(Class):
if not getattr(x, "__test__", True):
continue
funcobj = getimfunc(x)
- yield TestCaseFunction(name, parent=self, callobj=funcobj)
+ yield TestCaseFunction.from_parent(self, name=name, callobj=funcobj)
foundsomething = True
if not foundsomething:
@@ -59,7 +59,8 @@ class UnitTestCase(Class):
if runtest is not None:
ut = sys.modules.get("twisted.trial.unittest", None)
if ut is None or runtest != ut.TestCase.runTest:
- yield TestCaseFunction("runTest", parent=self)
+ # TODO: callobj consistency
+ yield TestCaseFunction.from_parent(self, name="runTest")
def _inject_setup_teardown_fixtures(self, cls):
"""Injects a hidden auto-use fixture to invoke setUpClass/setup_method and corresponding
@@ -190,20 +191,21 @@ class TestCaseFunction(Function):
def _handle_skip(self):
# implements the skipping machinery (see #2137)
# analog to pythons Lib/unittest/case.py:run
- testMethod = getattr(self._testcase, self._testcase._testMethodName)
+ test_method = getattr(self._testcase, self._testcase._testMethodName)
if getattr(self._testcase.__class__, "__unittest_skip__", False) or getattr(
- testMethod, "__unittest_skip__", False
+ test_method, "__unittest_skip__", False
):
# If the class or method was skipped.
skip_why = getattr(
self._testcase.__class__, "__unittest_skip_why__", ""
- ) or getattr(testMethod, "__unittest_skip_why__", "")
+ ) or getattr(test_method, "__unittest_skip_why__", "")
self._testcase._addSkip(self, self._testcase, skip_why)
return True
return False
def runtest(self):
if self.config.pluginmanager.get_plugin("pdbinvoke") is None:
+ # TODO: move testcase reporter into separate class, this shouldnt be on item
self._testcase(result=self)
else:
# disables tearDown and cleanups for post mortem debugging (see #1890)