From 55c349a9eba54ae7e61e306eb84e09bf4b7af91a Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Tue, 16 Apr 2013 10:19:20 +0200 Subject: [PATCH] charify pdb visible stack end finding by turning it into a function --- _pytest/pdb.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/_pytest/pdb.py b/_pytest/pdb.py index 1bf6086f5..fdcd1b142 100644 --- a/_pytest/pdb.py +++ b/_pytest/pdb.py @@ -86,15 +86,20 @@ def _postmortem_traceback(excinfo): return excinfo._excinfo[2] +def _find_last_non_hidden_frame(stack): + i = max(0, len(stack) - 1) + while i and stack[i][0].f_locals.get("__tracebackhide__", False): + i -= 1 + return i + + def post_mortem(t): pdb = py.std.pdb class Pdb(pdb.Pdb): def get_stack(self, f, t): stack, i = pdb.Pdb.get_stack(self, f, t) if f is None: - i = max(0, len(stack) - 1) - while i and stack[i][0].f_locals.get("__tracebackhide__", False): - i-=1 + i = _find_last_non_hidden_frame(stack) return stack, i p = Pdb() p.reset()