(self)
| 339 | |
| 340 | @unittest.expectedFailure # TODO: RUSTPYTHON |
| 341 | def test_annotated(self): |
| 342 | st1 = symtable.symtable('def f():\n x: int\n', 'test', 'exec') |
| 343 | st2 = st1.get_children()[1] |
| 344 | self.assertEqual(st2.get_type(), "function") |
| 345 | self.assertTrue(st2.lookup('x').is_local()) |
| 346 | self.assertTrue(st2.lookup('x').is_annotated()) |
| 347 | self.assertFalse(st2.lookup('x').is_global()) |
| 348 | st3 = symtable.symtable('def f():\n x = 1\n', 'test', 'exec') |
| 349 | st4 = st3.get_children()[1] |
| 350 | self.assertEqual(st4.get_type(), "function") |
| 351 | self.assertTrue(st4.lookup('x').is_local()) |
| 352 | self.assertFalse(st4.lookup('x').is_annotated()) |
| 353 | |
| 354 | # Test that annotations in the global scope are valid after the |
| 355 | # variable is declared as nonlocal. |
| 356 | st5 = symtable.symtable('global x\nx: int', 'test', 'exec') |
| 357 | self.assertTrue(st5.lookup("x").is_global()) |
| 358 | |
| 359 | # Test that annotations for nonlocals are valid after the |
| 360 | # variable is declared as nonlocal. |
| 361 | st6 = symtable.symtable('def g():\n' |
| 362 | ' x = 2\n' |
| 363 | ' def f():\n' |
| 364 | ' nonlocal x\n' |
| 365 | ' x: int', |
| 366 | 'test', 'exec') |
| 367 | |
| 368 | @unittest.expectedFailure # TODO: RUSTPYTHON |
| 369 | def test_imported(self): |
nothing calls this directly
no test coverage detected