diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-03-12 01:27:25 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-03-12 01:27:25 -0400 |
commit | 8bebfc205230d41429a88c98b56d45acf7e67226 (patch) | |
tree | fc1cc3af6273fa57e7fe8f247975b037540a9266 /test/test_ast.py | |
parent | 936a524263b90071d601b09a63f3c86117769b61 (diff) | |
download | external_python_mako-8bebfc205230d41429a88c98b56d45acf7e67226.tar.gz external_python_mako-8bebfc205230d41429a88c98b56d45acf7e67226.tar.bz2 external_python_mako-8bebfc205230d41429a88c98b56d45acf7e67226.zip |
- [feature] Added support for context managers,
i.e. "% with x as e:/ % endwith" support.
Courtesy Ben Trofatter [ticket:147]
Diffstat (limited to 'test/test_ast.py')
-rw-r--r-- | test/test_ast.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test_ast.py b/test/test_ast.py index adea08a..60ad6ec 100644 --- a/test/test_ast.py +++ b/test/test_ast.py @@ -189,6 +189,22 @@ def x(q): eq_(parsed.declared_identifiers, set(['x'])) eq_(parsed.undeclared_identifiers, set()) + def test_locate_identifiers_12(self): + code = """ +class ContextManager(object): + def __enter__(self): + return 1 + def __exit__(self, exc_type, exc_value, traceback): + pass + +with ContextManager() as x, ContextManager(): + print x +""" + parsed = ast.PythonCode(code, **exception_kwargs) + eq_(parsed.declared_identifiers, set(['ContextManager', 'x'])) + eq_(parsed.undeclared_identifiers, set()) + + def test_no_global_imports(self): code = """ from foo import * |