Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0a5bd51

Browse files
committed
Issue #13436: Add a test to make sure that ast.ImportFrom(level=None) works
1 parent dd745cc commit 0a5bd51

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Lib/test/test_ast.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,17 @@ def test_bad_integer(self):
548548
compile(mod, 'test', 'exec')
549549
self.assertIn("invalid integer value: None", str(cm.exception))
550550

551+
def test_level_as_none(self):
552+
body = [ast.ImportFrom(module='time',
553+
names=[ast.alias(name='sleep')],
554+
level=None,
555+
lineno=0, col_offset=0)]
556+
mod = ast.Module(body)
557+
code = compile(mod, 'test', 'exec')
558+
ns = {}
559+
exec(code, ns)
560+
self.assertIn('sleep', ns)
561+
551562

552563
class ASTValidatorTests(unittest.TestCase):
553564

0 commit comments

Comments
 (0)