diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-07-04 16:47:56 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-07-04 16:47:56 (GMT) |
commit | 75b44b3437e3ff6686629cdbffc2368e43e38ae0 (patch) | |
tree | 57097d6c3d0bfe981ed546b716528bbc8699a826 /Lib | |
parent | a7ee59b3d33327ec6f9f34da97d16344a1121199 (diff) | |
download | cpython-75b44b3437e3ff6686629cdbffc2368e43e38ae0.zip cpython-75b44b3437e3ff6686629cdbffc2368e43e38ae0.tar.gz cpython-75b44b3437e3ff6686629cdbffc2368e43e38ae0.tar.bz2 |
Issue #9130: Fix validation of relative imports in parser module.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_parser.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index a964877..e208d53 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -221,6 +221,12 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): self.check_suite("import sys as system, math") self.check_suite("import sys, math as my_math") + def test_relative_imports(self): + self.check_suite("from . import name") + self.check_suite("from .. import name") + self.check_suite("from .pkg import name") + self.check_suite("from ..pkg import name") + def test_pep263(self): self.check_suite("# -*- coding: iso-8859-1 -*-\n" "pass\n") @@ -519,6 +525,20 @@ class IllegalSyntaxTestCase(unittest.TestCase): (0, '')) self.check_bad_tree(tree, "malformed global ast") + def test_missing_import_source(self): + # from import a + tree = \ + (257, + (267, + (268, + (269, + (281, + (283, (1, 'from'), (1, 'import'), + (286, (284, (1, 'fred')))))), + (4, ''))), + (4, ''), (0, '')) + self.check_bad_tree(tree, "from import a") + class CompileTestCase(unittest.TestCase): |