MCPcopy Create free account
hub / github.com/ipython/ipython / test_nonlocal

Method test_nonlocal

IPython/core/tests/test_async_helpers.py:233–260  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

231 iprc(cell)
232
233 def test_nonlocal(self):
234 # fails if outer scope is not a function scope or if var not defined
235 with self.assertRaises(SyntaxError):
236 iprc("nonlocal x")
237 iprc("""
238 x = 1
239 def f():
240 nonlocal x
241 x = 10000
242 yield x
243 """)
244 iprc("""
245 def f():
246 def g():
247 nonlocal x
248 x = 10000
249 yield x
250 """)
251
252 # works if outer scope is a function scope and var exists
253 iprc("""
254 def f():
255 x = 20
256 def g():
257 nonlocal x
258 x = 10000
259 yield x
260 """)
261
262
263 def test_execute(self):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected