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

Method test_loopvar_in_only_one_scope

Lib/test/test_symtable.py:625–637  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

623 self.get_identifiers_recursive(ch, res)
624
625 def test_loopvar_in_only_one_scope(self):
626 # ensure that the loop variable appears only once in the symtable
627 comps = [
628 "[x for x in [1]]",
629 "{x for x in [1]}",
630 "{x:x*x for x in [1]}",
631 ]
632 for comp in comps:
633 with self.subTest(comp=comp):
634 st = symtable.symtable(comp, "?", "exec")
635 ids = []
636 self.get_identifiers_recursive(st, ids)
637 self.assertEqual(len([x for x in ids if x == 'x']), 1)
638
639
640class CommandLineTest(unittest.TestCase):

Callers

nothing calls this directly

Calls 3

subTestMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected