MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_annotated

Method test_annotated

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

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 9

get_typeMethod · 0.80
assertTrueMethod · 0.80
assertFalseMethod · 0.80
get_childrenMethod · 0.45
assertEqualMethod · 0.45
is_localMethod · 0.45
lookupMethod · 0.45
is_annotatedMethod · 0.45
is_globalMethod · 0.45

Tested by

no test coverage detected