MCPcopy
hub / github.com/pytest-dev/pytest / test_excinfo_getstatement

Function test_excinfo_getstatement

testing/code/test_excinfo.py:77–98  ·  testing/code/test_excinfo.py::test_excinfo_getstatement
()

Source from the content-addressed store, hash-verified

75
76
77def test_excinfo_getstatement():
78 def g():
79 raise ValueError
80
81 def f():
82 g()
83
84 try:
85 f()
86 except ValueError:
87 excinfo = _pytest._code.ExceptionInfo.from_current()
88 linenumbers = [
89 f.__code__.co_firstlineno - 1 + 4,
90 f.__code__.co_firstlineno - 1 + 1,
91 g.__code__.co_firstlineno - 1 + 1,
92 ]
93 values = list(excinfo.traceback)
94 foundlinenumbers = [x.lineno for x in values]
95 assert foundlinenumbers == linenumbers
96 class="cm"># for x in info:
97 class="cm"># print class="st">"%s:%d %s" %(x.path.relto(root), x.lineno, x.statement)
98 class="cm"># xxx
99
100
101class="cm"># testchain for getentries test below

Callers

nothing calls this directly

Calls 2

from_currentMethod · 0.80
fFunction · 0.70

Tested by

no test coverage detected