def test_scan_code__basic(monkeypatch, use_ast):
code = """
import os.path
from sys import maxint, exitfunc, platform
del exitfunc
def testfunc():
import shutil
"""
module = __scan_code(code, use_ast, monkeypatch)
assert len(module._deferred_imports) == 3
assert ([di[1][0] for di in module._deferred_imports]
== ['os.path', 'sys', 'shutil'])
assert module.is_global_attr('maxint')
assert module.is_global_attr('os')
assert module.is_global_attr('platform')
assert not module.is_global_attr('shutil') # not imported at module level
assert not module.is_global_attr('exitfunc')
test_modulegraph_more.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录