From 0a5bd51dd30762e3e3b0f3b00ffe7899b9c58317 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Fri, 29 Apr 2016 19:50:02 +0300 Subject: [PATCH] Issue #13436: Add a test to make sure that ast.ImportFrom(level=None) works --- Lib/test/test_ast.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index a025c20006c..7b43be6dfc2 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -548,6 +548,17 @@ class ASTHelpers_Test(unittest.TestCase): compile(mod, 'test', 'exec') self.assertIn("invalid integer value: None", str(cm.exception)) + def test_level_as_none(self): + body = [ast.ImportFrom(module='time', + names=[ast.alias(name='sleep')], + level=None, + lineno=0, col_offset=0)] + mod = ast.Module(body) + code = compile(mod, 'test', 'exec') + ns = {} + exec(code, ns) + self.assertIn('sleep', ns) + class ASTValidatorTests(unittest.TestCase):