Detect dynamic code explicitly in filter_traceback
This commit is contained in:
parent
11f100813e
commit
d1e00f6e19
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue