Fix situation where a traceback entry "path" returns a str object

Fix #1133
This commit is contained in:
Bruno Oliveira
2015-10-16 20:08:12 -03:00
parent 3b11995dbe
commit 311b0a9683
3 changed files with 47 additions and 16 deletions

View File

@@ -58,14 +58,17 @@ def _has_positional_arg(func):
def filter_traceback(entry):
# entry.path might sometimes return a str() object when the entry
# entry.path might sometimes return a str object when the entry
# points to dynamically generated code
# see https://bitbucket.org/pytest-dev/py/issues/71
raw_filename = entry.frame.code.raw.co_filename
is_generated = '<' in raw_filename and '>' in raw_filename
if is_generated:
return False
return entry.path != cutdir1 and not entry.path.relto(cutdir2)
# entry.path might point to an inexisting file, in which case it will
# alsso return a str object. see #1133
p = py.path.local(entry.path)
return p != cutdir1 and not p.relto(cutdir2)
def get_real_func(obj):