MCPcopy Index your code
hub / github.com/ipython/ipython / test_nonlocal

Method test_nonlocal

tests/test_async_helpers.py:362–395  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

360 iprc(cell)
361
362 def test_nonlocal(self):
363 # fails if outer scope is not a function scope or if var not defined
364 with self.assertRaises(SyntaxError):
365 iprc("nonlocal x")
366 iprc(
367 """
368 x = 1
369 def f():
370 nonlocal x
371 x = 10000
372 yield x
373 """
374 )
375 iprc(
376 """
377 def f():
378 def g():
379 nonlocal x
380 x = 10000
381 yield x
382 """
383 )
384
385 # works if outer scope is a function scope and var exists
386 iprc(
387 """
388 def f():
389 x = 20
390 def g():
391 nonlocal x
392 x = 10000
393 yield x
394 """
395 )
396
397 def test_execute(self):
398 iprc(

Callers

nothing calls this directly

Calls 1

iprcFunction · 0.85

Tested by

no test coverage detected