File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,6 +149,34 @@ def test_ipdb_magics():
149149 '''
150150
151151
152+ def test_ipdb_closure ():
153+ """Test evaluation of expressions which depend on closure.
154+
155+ In [1]: old_trace = sys.gettrace()
156+
157+ Create a function which triggers ipdb.
158+
159+ In [2]: def trigger_ipdb():
160+ ...: debugger.Pdb().set_trace()
161+
162+ In [3]: with PdbTestInput([
163+ ...: 'x = 1; sum(x * i for i in range(5))',
164+ ...: 'continue',
165+ ...: ]):
166+ ...: trigger_ipdb()
167+ ...> <doctest ...>(2)trigger_ipdb()
168+ 1 def trigger_ipdb():
169+ ----> 2 debugger.Pdb().set_trace()
170+ <BLANKLINE>
171+ ipdb> x = 1; sum(x * i for i in range(5))
172+ ipdb> continue
173+
174+ Restore previous trace function, e.g. for coverage.py
175+
176+ In [4]: sys.settrace(old_trace)
177+ """
178+
179+
152180def test_ipdb_magics2 ():
153181 """Test ipdb with a very short function.
154182
You can’t perform that action at this time.
0 commit comments