(self)
| 505 | |
| 506 | @unittest.expectedFailure # TODO: RUSTPYTHON |
| 507 | def test_symbol_repr(self): |
| 508 | self.assertEqual(repr(self.spam.lookup("glob")), |
| 509 | "<symbol 'glob': GLOBAL_IMPLICIT, USE>") |
| 510 | self.assertEqual(repr(self.spam.lookup("bar")), |
| 511 | "<symbol 'bar': GLOBAL_EXPLICIT, DEF_GLOBAL|DEF_LOCAL>") |
| 512 | self.assertEqual(repr(self.spam.lookup("a")), |
| 513 | "<symbol 'a': LOCAL, DEF_PARAM>") |
| 514 | self.assertEqual(repr(self.spam.lookup("internal")), |
| 515 | "<symbol 'internal': LOCAL, USE|DEF_LOCAL>") |
| 516 | self.assertEqual(repr(self.spam.lookup("other_internal")), |
| 517 | "<symbol 'other_internal': LOCAL, DEF_LOCAL>") |
| 518 | self.assertEqual(repr(self.internal.lookup("x")), |
| 519 | "<symbol 'x': FREE, USE>") |
| 520 | self.assertEqual(repr(self.other_internal.lookup("some_var")), |
| 521 | "<symbol 'some_var': FREE, USE|DEF_NONLOCAL|DEF_LOCAL>") |
| 522 | self.assertEqual(repr(self.GenericMine.lookup("T")), |
| 523 | "<symbol 'T': LOCAL, DEF_LOCAL|DEF_TYPE_PARAM>") |
| 524 | |
| 525 | st1 = symtable.symtable("[x for x in [1]]", "?", "exec") |
| 526 | self.assertEqual(repr(st1.lookup("x")), |
| 527 | "<symbol 'x': LOCAL, USE|DEF_LOCAL|DEF_COMP_ITER>") |
| 528 | |
| 529 | st2 = symtable.symtable("[(lambda: x) for x in [1]]", "?", "exec") |
| 530 | self.assertEqual(repr(st2.lookup("x")), |
| 531 | "<symbol 'x': CELL, DEF_LOCAL|DEF_COMP_ITER|DEF_COMP_CELL>") |
| 532 | |
| 533 | st3 = symtable.symtable("def f():\n" |
| 534 | " x = 1\n" |
| 535 | " class A:\n" |
| 536 | " x = 2\n" |
| 537 | " def method():\n" |
| 538 | " return x\n", |
| 539 | "?", "exec") |
| 540 | # child 0 is for __annotate__ |
| 541 | func_f = st3.get_children()[1] |
| 542 | class_A = func_f.get_children()[0] |
| 543 | self.assertEqual(repr(class_A.lookup('x')), |
| 544 | "<symbol 'x': LOCAL, DEF_LOCAL|DEF_FREE_CLASS>") |
| 545 | |
| 546 | def test_symtable_entry_repr(self): |
| 547 | expected = f"<symtable entry top({self.top.get_id()}), line {self.top.get_lineno()}>" |
nothing calls this directly
no test coverage detected