aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_ast.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-07-07 21:54:09 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-07-07 21:54:09 -0400
commit91b7e5f58477d4141fbf47552adbf929334dfe01 (patch)
tree4efcc36c4a4cf4f9b5260814b959c7e252e8ab7c /test/test_ast.py
parente9a1fd88f63c28d854f2b025d6699d80757b7dec (diff)
downloadexternal_python_mako-91b7e5f58477d4141fbf47552adbf929334dfe01.tar.gz
external_python_mako-91b7e5f58477d4141fbf47552adbf929334dfe01.tar.bz2
external_python_mako-91b7e5f58477d4141fbf47552adbf929334dfe01.zip
- [bug] Fixed some long-broken scoping behavior
involving variables declared in defs and such, which only became apparent when the strict_undefined flag was turned on. [ticket:192]
Diffstat (limited to 'test/test_ast.py')
-rw-r--r--test/test_ast.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_ast.py b/test/test_ast.py
index b0257b7..6051da6 100644
--- a/test/test_ast.py
+++ b/test/test_ast.py
@@ -208,6 +208,40 @@ def x(q):
eq_(parsed.undeclared_identifiers, set())
+ def test_locate_identifiers_12(self):
+ code = """
+def foo():
+ s = 1
+ def bar():
+ t = s
+"""
+ parsed = ast.PythonCode(code, **exception_kwargs)
+ eq_(parsed.declared_identifiers, set(['foo']))
+ eq_(parsed.undeclared_identifiers, set())
+
+ def test_locate_identifiers_13(self):
+ code = """
+def foo():
+ class Bat(object):
+ pass
+ Bat
+"""
+ parsed = ast.PythonCode(code, **exception_kwargs)
+ eq_(parsed.declared_identifiers, set(['foo']))
+ eq_(parsed.undeclared_identifiers, set())
+
+ def test_locate_identifiers_14(self):
+ code = """
+def foo():
+ class Bat(object):
+ pass
+ Bat
+
+print(Bat)
+"""
+ parsed = ast.PythonCode(code, **exception_kwargs)
+ eq_(parsed.declared_identifiers, set(['foo']))
+ eq_(parsed.undeclared_identifiers, set(['Bat']))
def test_no_global_imports(self):
code = """