MCPcopy Index your code
hub / github.com/python/cpython / testNestedNonLocal

Method testNestedNonLocal

Lib/test/test_scope.py:747–762  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

745 self.assertEqual(list(g(5)), [1, 2, 3, 4, 5])
746
747 def testNestedNonLocal(self):
748
749 def f(x):
750 def g():
751 nonlocal x
752 x -= 2
753 def h():
754 nonlocal x
755 x += 4
756 return x
757 return h
758 return g
759
760 g = f(1)
761 h = g()
762 self.assertEqual(h(), 3)
763
764 def testTopIsNotSignificant(self):
765 # See #9997.

Callers

nothing calls this directly

Calls 4

fFunction · 0.70
gFunction · 0.70
hClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected