summaryrefslogtreecommitdiff
path: root/Lib/test/test_symtable.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_symtable.py')
-rw-r--r--Lib/test/test_symtable.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py
index fbb1bdc9de..dfaee173ef 100644
--- a/Lib/test/test_symtable.py
+++ b/Lib/test/test_symtable.py
@@ -133,6 +133,17 @@ class SymtableTest(unittest.TestCase):
self.assertTrue(self.Mine.lookup("a_method").is_assigned())
self.assertFalse(self.internal.lookup("x").is_assigned())
+ def test_annotated(self):
+ st1 = symtable.symtable('def f():\n x: int\n', 'test', 'exec')
+ st2 = st1.get_children()[0]
+ self.assertTrue(st2.lookup('x').is_local())
+ self.assertTrue(st2.lookup('x').is_annotated())
+ self.assertFalse(st2.lookup('x').is_global())
+ st3 = symtable.symtable('def f():\n x = 1\n', 'test', 'exec')
+ st4 = st3.get_children()[0]
+ self.assertTrue(st4.lookup('x').is_local())
+ self.assertFalse(st4.lookup('x').is_annotated())
+
def test_imported(self):
self.assertTrue(self.top.lookup("sys").is_imported())
@@ -160,9 +171,11 @@ class SymtableTest(unittest.TestCase):
checkfilename("def f(x): foo)(", 14) # parse-time
checkfilename("def f(x): global x", 10) # symtable-build-time
symtable.symtable("pass", b"spam", "exec")
- with self.assertRaises(TypeError):
+ with self.assertWarns(DeprecationWarning), \
+ self.assertRaises(TypeError):
symtable.symtable("pass", bytearray(b"spam"), "exec")
- symtable.symtable("pass", memoryview(b"spam"), "exec")
+ with self.assertWarns(DeprecationWarning):
+ symtable.symtable("pass", memoryview(b"spam"), "exec")
with self.assertRaises(TypeError):
symtable.symtable("pass", list(b"spam"), "exec")