summaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py2/_pytest/runner.py
diff options
context:
space:
mode:
authorshadchin <[email protected]>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/python/pytest/py2/_pytest/runner.py
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/pytest/py2/_pytest/runner.py')
-rw-r--r--contrib/python/pytest/py2/_pytest/runner.py96
1 files changed, 48 insertions, 48 deletions
diff --git a/contrib/python/pytest/py2/_pytest/runner.py b/contrib/python/pytest/py2/_pytest/runner.py
index 076fb0f1bbd..34ae9177388 100644
--- a/contrib/python/pytest/py2/_pytest/runner.py
+++ b/contrib/python/pytest/py2/_pytest/runner.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
""" basic collect and runtest protocol implementations """
from __future__ import absolute_import
from __future__ import division
@@ -9,15 +9,15 @@ import os
import sys
from time import time
-import attr
+import attr
import six
from .reports import CollectErrorRepr
from .reports import CollectReport
from .reports import TestReport
from _pytest._code.code import ExceptionInfo
-from _pytest.compat import safe_str
-from _pytest.outcomes import Exit
+from _pytest.compat import safe_str
+from _pytest.outcomes import Exit
from _pytest.outcomes import Skipped
from _pytest.outcomes import TEST_OUTCOME
@@ -88,9 +88,9 @@ def runtestprotocol(item, log=True, nextitem=None):
rep = call_and_report(item, "setup", log)
reports = [rep]
if rep.passed:
- if item.config.getoption("setupshow", False):
+ if item.config.getoption("setupshow", False):
show_test_item(item)
- if not item.config.getoption("setuponly", False):
+ if not item.config.getoption("setuponly", False):
reports.append(call_and_report(item, "call", log))
reports.append(call_and_report(item, "teardown", log, nextitem=nextitem))
# after all teardown hooks have been called
@@ -184,7 +184,7 @@ def call_and_report(item, when, log=True, **kwds):
def check_interactive_exception(call, report):
return call.excinfo and not (
hasattr(report, "wasxfail")
- or call.excinfo.errisinstance(Skipped)
+ or call.excinfo.errisinstance(Skipped)
or call.excinfo.errisinstance(bdb.BdbQuit)
)
@@ -192,66 +192,66 @@ def check_interactive_exception(call, report):
def call_runtest_hook(item, when, **kwds):
hookname = "pytest_runtest_" + when
ihook = getattr(item.ihook, hookname)
- reraise = (Exit,)
- if not item.config.getoption("usepdb", False):
- reraise += (KeyboardInterrupt,)
- return CallInfo.from_call(
- lambda: ihook(item=item, **kwds), when=when, reraise=reraise
+ reraise = (Exit,)
+ if not item.config.getoption("usepdb", False):
+ reraise += (KeyboardInterrupt,)
+ return CallInfo.from_call(
+ lambda: ihook(item=item, **kwds), when=when, reraise=reraise
)
[email protected](repr=False)
[email protected](repr=False)
class CallInfo(object):
""" Result/Exception info a function invocation. """
- _result = attr.ib()
- # Optional[ExceptionInfo]
- excinfo = attr.ib()
- start = attr.ib()
- stop = attr.ib()
- when = attr.ib()
-
- @property
- def result(self):
- if self.excinfo is not None:
- raise AttributeError("{!r} has no valid result".format(self))
- return self._result
-
- @classmethod
- def from_call(cls, func, when, reraise=None):
+ _result = attr.ib()
+ # Optional[ExceptionInfo]
+ excinfo = attr.ib()
+ start = attr.ib()
+ stop = attr.ib()
+ when = attr.ib()
+
+ @property
+ def result(self):
+ if self.excinfo is not None:
+ raise AttributeError("{!r} has no valid result".format(self))
+ return self._result
+
+ @classmethod
+ def from_call(cls, func, when, reraise=None):
#: context of invocation: one of "setup", "call",
#: "teardown", "memocollect"
- start = time()
- excinfo = None
+ start = time()
+ excinfo = None
try:
- result = func()
- except: # noqa
- excinfo = ExceptionInfo.from_current()
- if reraise is not None and excinfo.errisinstance(reraise):
+ result = func()
+ except: # noqa
+ excinfo = ExceptionInfo.from_current()
+ if reraise is not None and excinfo.errisinstance(reraise):
raise
- result = None
- stop = time()
- return cls(start=start, stop=stop, when=when, result=result, excinfo=excinfo)
+ result = None
+ stop = time()
+ return cls(start=start, stop=stop, when=when, result=result, excinfo=excinfo)
def __repr__(self):
- if self.excinfo is not None:
- status = "exception"
- value = self.excinfo.value
+ if self.excinfo is not None:
+ status = "exception"
+ value = self.excinfo.value
else:
- # TODO: investigate unification
- value = repr(self._result)
- status = "result"
- return "<CallInfo when={when!r} {status}: {value}>".format(
- when=self.when, value=safe_str(value), status=status
- )
+ # TODO: investigate unification
+ value = repr(self._result)
+ status = "result"
+ return "<CallInfo when={when!r} {status}: {value}>".format(
+ when=self.when, value=safe_str(value), status=status
+ )
def pytest_runtest_makereport(item, call):
- return TestReport.from_item_and_call(item, call)
+ return TestReport.from_item_and_call(item, call)
def pytest_make_collect_report(collector):
- call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
+ call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
longrepr = None
if not call.excinfo:
outcome = "passed"