summaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py2/_pytest/_code
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/_code
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/pytest/py2/_pytest/_code')
-rw-r--r--contrib/python/pytest/py2/_pytest/_code/__init__.py2
-rw-r--r--contrib/python/pytest/py2/_pytest/_code/_py2traceback.py2
-rw-r--r--contrib/python/pytest/py2/_pytest/_code/code.py202
-rw-r--r--contrib/python/pytest/py2/_pytest/_code/source.py14
4 files changed, 110 insertions, 110 deletions
diff --git a/contrib/python/pytest/py2/_pytest/_code/__init__.py b/contrib/python/pytest/py2/_pytest/_code/__init__.py
index 989743ea510..1394b2b10e6 100644
--- a/contrib/python/pytest/py2/_pytest/_code/__init__.py
+++ b/contrib/python/pytest/py2/_pytest/_code/__init__.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
""" python inspection/code generation API """
from __future__ import absolute_import
from __future__ import division
diff --git a/contrib/python/pytest/py2/_pytest/_code/_py2traceback.py b/contrib/python/pytest/py2/_pytest/_code/_py2traceback.py
index cd614642b77..faacc02166e 100644
--- a/contrib/python/pytest/py2/_pytest/_code/_py2traceback.py
+++ b/contrib/python/pytest/py2/_pytest/_code/_py2traceback.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
# copied from python-2.7.3's traceback.py
# CHANGES:
# - some_str is replaced, trying to create unicode strings
diff --git a/contrib/python/pytest/py2/_pytest/_code/code.py b/contrib/python/pytest/py2/_pytest/_code/code.py
index 38ca0a5b19b..175d6fda01d 100644
--- a/contrib/python/pytest/py2/_pytest/_code/code.py
+++ b/contrib/python/pytest/py2/_pytest/_code/code.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@@ -17,8 +17,8 @@ import py
from six import text_type
import _pytest
-from _pytest._io.saferepr import safeformat
-from _pytest._io.saferepr import saferepr
+from _pytest._io.saferepr import safeformat
+from _pytest._io.saferepr import saferepr
from _pytest.compat import _PY2
from _pytest.compat import _PY3
from _pytest.compat import PY35
@@ -138,12 +138,12 @@ class Frame(object):
"""
f_locals = self.f_locals.copy()
f_locals.update(vars)
- exec(code, self.f_globals, f_locals)
+ exec(code, self.f_globals, f_locals)
def repr(self, object):
""" return a 'safe' (non-recursive, one-line) string repr for 'object'
"""
- return saferepr(object)
+ return saferepr(object)
def is_true(self, object):
return object
@@ -241,20 +241,20 @@ class TracebackEntry(object):
def ishidden(self):
""" return True if the current frame has a var __tracebackhide__
- resolving to True.
+ resolving to True.
If __tracebackhide__ is a callable, it gets called with the
ExceptionInfo instance and can decide whether to hide the traceback.
mostly for internal use
"""
- f = self.frame
- tbh = f.f_locals.get(
- "__tracebackhide__", f.f_globals.get("__tracebackhide__", False)
- )
- if tbh and callable(tbh):
+ f = self.frame
+ tbh = f.f_locals.get(
+ "__tracebackhide__", f.f_globals.get("__tracebackhide__", False)
+ )
+ if tbh and callable(tbh):
return tbh(None if self._excinfo is None else self._excinfo())
- return tbh
+ return tbh
def __str__(self):
try:
@@ -385,7 +385,7 @@ co_equal = compile(
)
[email protected](repr=False)
[email protected](repr=False)
class ExceptionInfo(object):
""" wraps sys.exc_info() objects and offers
help for navigating the traceback.
@@ -395,76 +395,76 @@ class ExceptionInfo(object):
"AssertionError(u'assert " if _PY2 else "AssertionError('assert "
)
- _excinfo = attr.ib()
- _striptext = attr.ib(default="")
- _traceback = attr.ib(default=None)
-
- @classmethod
- def from_current(cls, exprinfo=None):
- """returns an ExceptionInfo matching the current traceback
-
- .. warning::
-
- Experimental API
-
-
- :param exprinfo: a text string helping to determine if we should
- strip ``AssertionError`` from the output, defaults
- to the exception message/``__str__()``
- """
- tup = sys.exc_info()
- assert tup[0] is not None, "no current exception"
- _striptext = ""
- if exprinfo is None and isinstance(tup[1], AssertionError):
- exprinfo = getattr(tup[1], "msg", None)
- if exprinfo is None:
- exprinfo = saferepr(tup[1])
- if exprinfo and exprinfo.startswith(cls._assert_start_repr):
- _striptext = "AssertionError: "
-
- return cls(tup, _striptext)
-
- @classmethod
- def for_later(cls):
- """return an unfilled ExceptionInfo
- """
- return cls(None)
-
- @property
- def type(self):
- """the exception class"""
- return self._excinfo[0]
-
- @property
- def value(self):
- """the exception value"""
- return self._excinfo[1]
-
- @property
- def tb(self):
- """the exception raw traceback"""
- return self._excinfo[2]
-
- @property
- def typename(self):
- """the type name of the exception"""
- return self.type.__name__
-
- @property
- def traceback(self):
- """the traceback"""
- if self._traceback is None:
- self._traceback = Traceback(self.tb, excinfo=ref(self))
- return self._traceback
-
- @traceback.setter
- def traceback(self, value):
- self._traceback = value
-
+ _excinfo = attr.ib()
+ _striptext = attr.ib(default="")
+ _traceback = attr.ib(default=None)
+
+ @classmethod
+ def from_current(cls, exprinfo=None):
+ """returns an ExceptionInfo matching the current traceback
+
+ .. warning::
+
+ Experimental API
+
+
+ :param exprinfo: a text string helping to determine if we should
+ strip ``AssertionError`` from the output, defaults
+ to the exception message/``__str__()``
+ """
+ tup = sys.exc_info()
+ assert tup[0] is not None, "no current exception"
+ _striptext = ""
+ if exprinfo is None and isinstance(tup[1], AssertionError):
+ exprinfo = getattr(tup[1], "msg", None)
+ if exprinfo is None:
+ exprinfo = saferepr(tup[1])
+ if exprinfo and exprinfo.startswith(cls._assert_start_repr):
+ _striptext = "AssertionError: "
+
+ return cls(tup, _striptext)
+
+ @classmethod
+ def for_later(cls):
+ """return an unfilled ExceptionInfo
+ """
+ return cls(None)
+
+ @property
+ def type(self):
+ """the exception class"""
+ return self._excinfo[0]
+
+ @property
+ def value(self):
+ """the exception value"""
+ return self._excinfo[1]
+
+ @property
+ def tb(self):
+ """the exception raw traceback"""
+ return self._excinfo[2]
+
+ @property
+ def typename(self):
+ """the type name of the exception"""
+ return self.type.__name__
+
+ @property
+ def traceback(self):
+ """the traceback"""
+ if self._traceback is None:
+ self._traceback = Traceback(self.tb, excinfo=ref(self))
+ return self._traceback
+
+ @traceback.setter
+ def traceback(self, value):
+ self._traceback = value
+
def __repr__(self):
- if self._excinfo is None:
- return "<ExceptionInfo for raises contextmanager>"
- return "<ExceptionInfo %s tblen=%d>" % (self.typename, len(self.traceback))
+ if self._excinfo is None:
+ return "<ExceptionInfo for raises contextmanager>"
+ return "<ExceptionInfo %s tblen=%d>" % (self.typename, len(self.traceback))
def exconly(self, tryshort=False):
""" return the exception as a string
@@ -552,11 +552,11 @@ class ExceptionInfo(object):
return fmt.repr_excinfo(self)
def __str__(self):
- if self._excinfo is None:
+ if self._excinfo is None:
return repr(self)
- entry = self.traceback[-1]
- loc = ReprFileLocation(entry.path, entry.lineno + 1, self.exconly())
- return str(loc)
+ entry = self.traceback[-1]
+ loc = ReprFileLocation(entry.path, entry.lineno + 1, self.exconly())
+ return str(loc)
def __unicode__(self):
entry = self.traceback[-1]
@@ -565,20 +565,20 @@ class ExceptionInfo(object):
def match(self, regexp):
"""
- Check whether the regular expression 'regexp' is found in the string
- representation of the exception using ``re.search``. If it matches
- then True is returned (so that it is possible to write
- ``assert excinfo.match()``). If it doesn't match an AssertionError is
- raised.
+ Check whether the regular expression 'regexp' is found in the string
+ representation of the exception using ``re.search``. If it matches
+ then True is returned (so that it is possible to write
+ ``assert excinfo.match()``). If it doesn't match an AssertionError is
+ raised.
"""
__tracebackhide__ = True
- value = (
- text_type(self.value) if isinstance(regexp, text_type) else str(self.value)
- )
- if not re.search(regexp, value):
- raise AssertionError(
- u"Pattern {!r} not found in {!r}".format(regexp, value)
- )
+ value = (
+ text_type(self.value) if isinstance(regexp, text_type) else str(self.value)
+ )
+ if not re.search(regexp, value):
+ raise AssertionError(
+ u"Pattern {!r} not found in {!r}".format(regexp, value)
+ )
return True
@@ -624,7 +624,7 @@ class FormattedExcinfo(object):
if self.funcargs:
args = []
for argname, argvalue in entry.frame.getargs(var=True):
- args.append((argname, saferepr(argvalue)))
+ args.append((argname, saferepr(argvalue)))
return ReprFuncArgs(args)
def get_source(self, source, line_index=-1, excinfo=None, short=False):
@@ -677,9 +677,9 @@ class FormattedExcinfo(object):
# _repr() function, which is only reprlib.Repr in
# disguise, so is very configurable.
if self.truncate_locals:
- str_repr = saferepr(value)
+ str_repr = saferepr(value)
else:
- str_repr = safeformat(value)
+ str_repr = safeformat(value)
# if len(str_repr) < 70 or not isinstance(value,
# (list, tuple, dict)):
lines.append("%-10s = %s" % (name, str_repr))
diff --git a/contrib/python/pytest/py2/_pytest/_code/source.py b/contrib/python/pytest/py2/_pytest/_code/source.py
index 74e9c776000..b35e97b9cec 100644
--- a/contrib/python/pytest/py2/_pytest/_code/source.py
+++ b/contrib/python/pytest/py2/_pytest/_code/source.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@@ -128,8 +128,8 @@ class Source(object):
else:
source = str(self)
try:
- ast.parse(source)
- except (SyntaxError, ValueError, TypeError):
+ ast.parse(source)
+ except (SyntaxError, ValueError, TypeError):
return False
else:
return True
@@ -199,9 +199,9 @@ def compile_(source, filename=None, mode="exec", flags=0, dont_inherit=0):
def getfslineno(obj):
""" Return source location (path, lineno) for the given object.
- If the source cannot be determined return ("", -1).
-
- The line number is 0-based.
+ If the source cannot be determined return ("", -1).
+
+ The line number is 0-based.
"""
from .code import Code
@@ -235,7 +235,7 @@ def getfslineno(obj):
def findsource(obj):
try:
sourcelines, lineno = inspect.findsource(obj)
- except Exception:
+ except Exception:
return None, -1
source = Source()
source.lines = [line.rstrip() for line in sourcelines]