Changeset 391 for python/trunk/Lib/test/test_symtable.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/test/test_symtable.py
r2 r391 4 4 import symtable 5 5 import unittest 6 import warnings7 6 8 7 from test import test_support … … 45 44 class SymtableTest(unittest.TestCase): 46 45 47 with warnings.catch_warnings(): 48 # Ignore warnings about "from blank import *" 49 warnings.simplefilter("ignore", SyntaxWarning) 46 with test_support.check_warnings( 47 ("import \* only allowed at module level", SyntaxWarning)): 50 48 top = symtable.symtable(TEST_CODE, "?", "exec") 51 49 # These correspond to scopes in TEST_CODE … … 55 53 internal = find_block(spam, "internal") 56 54 foo = find_block(top, "foo") 57 58 def test_noops(self):59 # Check methods that don't work. They should warn and return False.60 def check(w, msg):61 self.assertEqual(str(w.message), msg)62 sym = self.top.lookup("glob")63 with test_support.check_warnings() as w:64 warnings.simplefilter("always", DeprecationWarning)65 self.assertFalse(sym.is_vararg())66 check(w, "is_vararg() is obsolete and will be removed")67 w.reset()68 self.assertFalse(sym.is_keywordarg())69 check(w, "is_keywordarg() is obsolete and will be removed")70 w.reset()71 self.assertFalse(sym.is_in_tuple())72 check(w, "is_in_tuple() is obsolete and will be removed")73 55 74 56 def test_type(self): … … 107 89 def test_function_info(self): 108 90 func = self.spam 109 self.assertEqual( func.get_parameters(), ("a", "b", "kw", "var"))110 self.assertEqual(func.get_locals(),111 ("a", "b", "bar", "internal", "kw", "var", "x"))112 self.assertEqual( func.get_globals(), ("bar", "glob"))91 self.assertEqual(sorted(func.get_parameters()), ["a", "b", "kw", "var"]) 92 expected = ["a", "b", "internal", "kw", "var", "x"] 93 self.assertEqual(sorted(func.get_locals()), expected) 94 self.assertEqual(sorted(func.get_globals()), ["bar", "glob"]) 113 95 self.assertEqual(self.internal.get_frees(), ("x",)) 114 96 … … 149 131 self.assertFalse(self.spam.lookup("x").is_namespace()) 150 132 151 self.assert _(self.top.lookup("spam").get_namespace() is self.spam)133 self.assertTrue(self.top.lookup("spam").get_namespace() is self.spam) 152 134 ns_test = self.top.lookup("namespace_test") 153 135 self.assertEqual(len(ns_test.get_namespaces()), 2)
Note:
See TracChangeset
for help on using the changeset viewer.