-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
good first issueeasy issue that is friendly to new contributoreasy issue that is friendly to new contributortype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
py.test version: 3.6.0
Python version: 3.6.4
The result attribute of CallInfo objects is assigned in __init__ as the result of calling the test function. This means that result is only defined after the test function has finished executing.
If however, the test function extracts local variables from the stack (and does anything causing __repr__ to be called on them) this causes an AttributeError since CallInfo.__repr__ expects result to be defined.
Minimum example:
import sys
from traceback import print_list, StackSummary, walk_stack
def print_stack():
stack = StackSummary.extract(walk_stack(sys._getframe().f_back), capture_locals=True)
stack.reverse()
print_list(stack)
def test_bla():
print_stack()
# ^ This will crash with `AttributeError: 'CallInfo' object has no attribute 'result'`
assert 1 == 1Metadata
Metadata
Assignees
Labels
good first issueeasy issue that is friendly to new contributoreasy issue that is friendly to new contributortype: bugproblem that needs to be addressedproblem that needs to be addressed