Issue #13436: Add a test to make sure that ast.ImportFrom(level=None) works

This commit is contained in:
Berker Peksag 2016-04-29 19:50:02 +03:00
parent dd745cc3ff
commit 0a5bd51dd3
1 changed files with 11 additions and 0 deletions

View File

@ -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):