summaryrefslogtreecommitdiff
path: root/Lib/test/test_unparse.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-05 10:39:52 -0700
committerGitHub <noreply@github.com>2022-09-05 10:39:52 -0700
commit6cc31af657a0aaf5a8ba0564b35124f1ca542287 (patch)
tree4b97e2e56a271e3f46b354722556a4db82811206 /Lib/test/test_unparse.py
parente13f49a0bc253f1b8939fd505547986183761768 (diff)
downloadcpython-git-6cc31af657a0aaf5a8ba0564b35124f1ca542287.tar.gz
gh-92986: Fix ast.unparse when ImportFrom.level is None (GH-92992)
This doesn't happen naturally, but is allowed by the ASDL and compiler. We don't want to change ASDL for backward compatibility reasons (GH-57645, GH-92987) (cherry picked from commit 200c9a8da0e2b892c476807e986009c01327e781) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_unparse.py')
-rw-r--r--Lib/test/test_unparse.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py
index 33e1149bfd..6e38c5e846 100644
--- a/Lib/test/test_unparse.py
+++ b/Lib/test/test_unparse.py
@@ -341,6 +341,12 @@ class UnparseTestCase(ASTTestCase):
def test_invalid_yield_from(self):
self.check_invalid(ast.YieldFrom(value=None))
+ def test_import_from_level_none(self):
+ tree = ast.ImportFrom(module='mod', names=[ast.alias(name='x')])
+ self.assertEqual(ast.unparse(tree), "from mod import x")
+ tree = ast.ImportFrom(module='mod', names=[ast.alias(name='x')], level=None)
+ self.assertEqual(ast.unparse(tree), "from mod import x")
+
def test_docstrings(self):
docstrings = (
'this ends with double quote"',