Detect dynamic code explicitly in filter_traceback

This commit is contained in:
Bruno Oliveira 2015-09-30 17:15:53 -03:00
parent 11f100813e
commit d1e00f6e19
2 changed files with 8 additions and 4 deletions

View File

@ -49,10 +49,14 @@ def _has_positional_arg(func):
def filter_traceback(entry):
# ensure entry.path is always a py.path.local object
# 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
path = py.path.local(entry.path)
return path != cutdir1 and not path.relto(cutdir2)
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)
def get_real_func(obj):

View File

@ -778,7 +778,7 @@ class TestTracebackCutting:
tb = py.code.Traceback(tb)
assert isinstance(tb[-1].path, str) # symptom of the py.code bug
assert filter_traceback(tb[-1])
assert not filter_traceback(tb[-1])
class TestReportInfo: