summaryrefslogtreecommitdiff
path: root/Lib/test/test_parser.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-07-04 18:11:51 +0000
committerMark Dickinson <dickinsm@gmail.com>2010-07-04 18:11:51 +0000
commitf5c5c2e676aef723bedb4ea953ba71f7a72ac060 (patch)
tree1de9d0ba39c581932d4ec96b72e7e845faf4bd3f /Lib/test/test_parser.py
parent70c99ef9d14b1096e8327aae39fb5fea56e612c4 (diff)
downloadcpython-f5c5c2e676aef723bedb4ea953ba71f7a72ac060.tar.gz
Issue #9130: Fix validation of relative imports in parser module.
Diffstat (limited to 'Lib/test/test_parser.py')
-rw-r--r--Lib/test/test_parser.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 96f14f62bb..ade74311a5 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -189,6 +189,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")
@@ -464,6 +470,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):