aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py2/_pytest/reports.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/py2/_pytest/reports.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/py2/_pytest/reports.py')
-rw-r--r--contrib/python/pytest/py2/_pytest/reports.py374
1 files changed, 187 insertions, 187 deletions
diff --git a/contrib/python/pytest/py2/_pytest/reports.py b/contrib/python/pytest/py2/_pytest/reports.py
index 8e5106e069..0bba6762c3 100644
--- a/contrib/python/pytest/py2/_pytest/reports.py
+++ b/contrib/python/pytest/py2/_pytest/reports.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from pprint import pprint
-import py
+import py
import six
-
+
from _pytest._code.code import ExceptionInfo
from _pytest._code.code import ReprEntry
from _pytest._code.code import ReprEntryNative
@@ -12,111 +12,111 @@ from _pytest._code.code import ReprFileLocation
from _pytest._code.code import ReprFuncArgs
from _pytest._code.code import ReprLocals
from _pytest._code.code import ReprTraceback
-from _pytest._code.code import TerminalRepr
+from _pytest._code.code import TerminalRepr
from _pytest.outcomes import skip
from _pytest.pathlib import Path
-
-
-def getslaveinfoline(node):
- try:
- return node._slaveinfocache
- except AttributeError:
- d = node.slaveinfo
- ver = "%s.%s.%s" % d["version_info"][:3]
- node._slaveinfocache = s = "[%s] %s -- Python %s %s" % (
- d["id"],
- d["sysplatform"],
- ver,
- d["executable"],
- )
- return s
-
-
-class BaseReport(object):
+
+
+def getslaveinfoline(node):
+ try:
+ return node._slaveinfocache
+ except AttributeError:
+ d = node.slaveinfo
+ ver = "%s.%s.%s" % d["version_info"][:3]
+ node._slaveinfocache = s = "[%s] %s -- Python %s %s" % (
+ d["id"],
+ d["sysplatform"],
+ ver,
+ d["executable"],
+ )
+ return s
+
+
+class BaseReport(object):
when = None
location = None
- def __init__(self, **kw):
- self.__dict__.update(kw)
-
- def toterminal(self, out):
- if hasattr(self, "node"):
- out.line(getslaveinfoline(self.node))
-
- longrepr = self.longrepr
- if longrepr is None:
- return
-
- if hasattr(longrepr, "toterminal"):
- longrepr.toterminal(out)
- else:
- try:
- out.line(longrepr)
- except UnicodeEncodeError:
- out.line("<unprintable longrepr>")
-
- def get_sections(self, prefix):
- for name, content in self.sections:
- if name.startswith(prefix):
- yield prefix, content
-
- @property
- def longreprtext(self):
- """
- Read-only property that returns the full string representation
- of ``longrepr``.
-
- .. versionadded:: 3.0
- """
- tw = py.io.TerminalWriter(stringio=True)
- tw.hasmarkup = False
- self.toterminal(tw)
- exc = tw.stringio.getvalue()
- return exc.strip()
-
- @property
- def caplog(self):
- """Return captured log lines, if log capturing is enabled
-
- .. versionadded:: 3.5
- """
- return "\n".join(
- content for (prefix, content) in self.get_sections("Captured log")
- )
-
- @property
- def capstdout(self):
- """Return captured text from stdout, if capturing is enabled
-
- .. versionadded:: 3.0
- """
- return "".join(
- content for (prefix, content) in self.get_sections("Captured stdout")
- )
-
- @property
- def capstderr(self):
- """Return captured text from stderr, if capturing is enabled
-
- .. versionadded:: 3.0
- """
- return "".join(
- content for (prefix, content) in self.get_sections("Captured stderr")
- )
-
- passed = property(lambda x: x.outcome == "passed")
- failed = property(lambda x: x.outcome == "failed")
- skipped = property(lambda x: x.outcome == "skipped")
-
- @property
- def fspath(self):
- return self.nodeid.split("::")[0]
-
+ def __init__(self, **kw):
+ self.__dict__.update(kw)
+
+ def toterminal(self, out):
+ if hasattr(self, "node"):
+ out.line(getslaveinfoline(self.node))
+
+ longrepr = self.longrepr
+ if longrepr is None:
+ return
+
+ if hasattr(longrepr, "toterminal"):
+ longrepr.toterminal(out)
+ else:
+ try:
+ out.line(longrepr)
+ except UnicodeEncodeError:
+ out.line("<unprintable longrepr>")
+
+ def get_sections(self, prefix):
+ for name, content in self.sections:
+ if name.startswith(prefix):
+ yield prefix, content
+
+ @property
+ def longreprtext(self):
+ """
+ Read-only property that returns the full string representation
+ of ``longrepr``.
+
+ .. versionadded:: 3.0
+ """
+ tw = py.io.TerminalWriter(stringio=True)
+ tw.hasmarkup = False
+ self.toterminal(tw)
+ exc = tw.stringio.getvalue()
+ return exc.strip()
+
+ @property
+ def caplog(self):
+ """Return captured log lines, if log capturing is enabled
+
+ .. versionadded:: 3.5
+ """
+ return "\n".join(
+ content for (prefix, content) in self.get_sections("Captured log")
+ )
+
+ @property
+ def capstdout(self):
+ """Return captured text from stdout, if capturing is enabled
+
+ .. versionadded:: 3.0
+ """
+ return "".join(
+ content for (prefix, content) in self.get_sections("Captured stdout")
+ )
+
+ @property
+ def capstderr(self):
+ """Return captured text from stderr, if capturing is enabled
+
+ .. versionadded:: 3.0
+ """
+ return "".join(
+ content for (prefix, content) in self.get_sections("Captured stderr")
+ )
+
+ passed = property(lambda x: x.outcome == "passed")
+ failed = property(lambda x: x.outcome == "failed")
+ skipped = property(lambda x: x.outcome == "skipped")
+
+ @property
+ def fspath(self):
+ return self.nodeid.split("::")[0]
+
@property
def count_towards_summary(self):
"""
**Experimental**
-
+
Returns True if this report should be counted towards the totals shown at the end of the
test session: "1 passed, 1 failure, etc".
@@ -278,70 +278,70 @@ def _report_unserialization_failure(type_name, report_class, reportdict):
raise RuntimeError(stream.getvalue())
-class TestReport(BaseReport):
- """ Basic test report object (also used for setup and teardown calls if
- they fail).
- """
-
+class TestReport(BaseReport):
+ """ Basic test report object (also used for setup and teardown calls if
+ they fail).
+ """
+
__test__ = False
- def __init__(
- self,
- nodeid,
- location,
- keywords,
- outcome,
- longrepr,
- when,
- sections=(),
- duration=0,
- user_properties=None,
- **extra
- ):
- #: normalized collection node id
- self.nodeid = nodeid
-
- #: a (filesystempath, lineno, domaininfo) tuple indicating the
- #: actual location of a test item - it might be different from the
- #: collected one e.g. if a method is inherited from a different module.
- self.location = location
-
- #: a name -> value dictionary containing all keywords and
- #: markers associated with a test invocation.
- self.keywords = keywords
-
- #: test outcome, always one of "passed", "failed", "skipped".
- self.outcome = outcome
-
- #: None or a failure representation.
- self.longrepr = longrepr
-
- #: one of 'setup', 'call', 'teardown' to indicate runtest phase.
- self.when = when
-
- #: user properties is a list of tuples (name, value) that holds user
- #: defined properties of the test
- self.user_properties = list(user_properties or [])
-
- #: list of pairs ``(str, str)`` of extra information which needs to
- #: marshallable. Used by pytest to add captured text
- #: from ``stdout`` and ``stderr``, but may be used by other plugins
- #: to add arbitrary information to reports.
- self.sections = list(sections)
-
- #: time it took to run just the test
- self.duration = duration
-
- self.__dict__.update(extra)
-
- def __repr__(self):
+ def __init__(
+ self,
+ nodeid,
+ location,
+ keywords,
+ outcome,
+ longrepr,
+ when,
+ sections=(),
+ duration=0,
+ user_properties=None,
+ **extra
+ ):
+ #: normalized collection node id
+ self.nodeid = nodeid
+
+ #: a (filesystempath, lineno, domaininfo) tuple indicating the
+ #: actual location of a test item - it might be different from the
+ #: collected one e.g. if a method is inherited from a different module.
+ self.location = location
+
+ #: a name -> value dictionary containing all keywords and
+ #: markers associated with a test invocation.
+ self.keywords = keywords
+
+ #: test outcome, always one of "passed", "failed", "skipped".
+ self.outcome = outcome
+
+ #: None or a failure representation.
+ self.longrepr = longrepr
+
+ #: one of 'setup', 'call', 'teardown' to indicate runtest phase.
+ self.when = when
+
+ #: user properties is a list of tuples (name, value) that holds user
+ #: defined properties of the test
+ self.user_properties = list(user_properties or [])
+
+ #: list of pairs ``(str, str)`` of extra information which needs to
+ #: marshallable. Used by pytest to add captured text
+ #: from ``stdout`` and ``stderr``, but may be used by other plugins
+ #: to add arbitrary information to reports.
+ self.sections = list(sections)
+
+ #: time it took to run just the test
+ self.duration = duration
+
+ self.__dict__.update(extra)
+
+ def __repr__(self):
return "<%s %r when=%r outcome=%r>" % (
self.__class__.__name__,
- self.nodeid,
- self.when,
- self.outcome,
- )
-
+ self.nodeid,
+ self.when,
+ self.outcome,
+ )
+
@classmethod
def from_item_and_call(cls, item, call):
"""
@@ -384,37 +384,37 @@ class TestReport(BaseReport):
duration,
user_properties=item.user_properties,
)
-
-
+
+
class CollectReport(BaseReport):
when = "collect"
-
- def __init__(self, nodeid, outcome, longrepr, result, sections=(), **extra):
- self.nodeid = nodeid
- self.outcome = outcome
- self.longrepr = longrepr
- self.result = result or []
- self.sections = list(sections)
- self.__dict__.update(extra)
-
- @property
- def location(self):
- return (self.fspath, None, self.fspath)
-
- def __repr__(self):
- return "<CollectReport %r lenresult=%s outcome=%r>" % (
- self.nodeid,
- len(self.result),
- self.outcome,
- )
-
-
-class CollectErrorRepr(TerminalRepr):
- def __init__(self, msg):
- self.longrepr = msg
-
- def toterminal(self, out):
- out.line(self.longrepr, red=True)
+
+ def __init__(self, nodeid, outcome, longrepr, result, sections=(), **extra):
+ self.nodeid = nodeid
+ self.outcome = outcome
+ self.longrepr = longrepr
+ self.result = result or []
+ self.sections = list(sections)
+ self.__dict__.update(extra)
+
+ @property
+ def location(self):
+ return (self.fspath, None, self.fspath)
+
+ def __repr__(self):
+ return "<CollectReport %r lenresult=%s outcome=%r>" % (
+ self.nodeid,
+ len(self.result),
+ self.outcome,
+ )
+
+
+class CollectErrorRepr(TerminalRepr):
+ def __init__(self, msg):
+ self.longrepr = msg
+
+ def toterminal(self, out):
+ out.line(self.longrepr, red=True)
def pytest_report_to_serializable(report):