summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-07-04 18:16:43 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-07-04 18:16:43 (GMT)
commit1b9b5727cc85c4aec17c2fa79f9491d986dbb00e (patch)
treeb3477eca8792ea14563fb6167e962820e34b7f59 /Lib
parent31a0f86e368c980b751bdc0b377e42322cf2566d (diff)
downloadcpython-1b9b5727cc85c4aec17c2fa79f9491d986dbb00e.zip
cpython-1b9b5727cc85c4aec17c2fa79f9491d986dbb00e.tar.gz
cpython-1b9b5727cc85c4aec17c2fa79f9491d986dbb00e.tar.bz2
Merged revisions 82552-82553 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82552 | mark.dickinson | 2010-07-04 19:11:51 +0100 (Sun, 04 Jul 2010) | 2 lines Issue #9130: Fix validation of relative imports in parser module. ........ r82553 | mark.dickinson | 2010-07-04 19:15:26 +0100 (Sun, 04 Jul 2010) | 1 line Fix symbol numbers in test_parser test. ........
Diffstat (limited to 'Lib')
-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 3a7bbe9..17111b0 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -190,6 +190,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")
@@ -459,6 +465,20 @@ class IllegalSyntaxTestCase(unittest.TestCase):
(0, ''))
self.check_bad_tree(tree, "malformed global ast")
+ def test_missing_import_source(self):
+ # from import fred
+ tree = \
+ (257,
+ (268,
+ (269,
+ (270,
+ (282,
+ (284, (1, 'from'), (1, 'import'),
+ (287, (285, (1, 'fred')))))),
+ (4, ''))),
+ (4, ''), (0, ''))
+ self.check_bad_tree(tree, "from import fred")
+
class CompileTestCase(unittest.TestCase):