- Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathtest_lazy_imports.py
39 lines (29 loc) · 1.09 KB
/
test_lazy_imports.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
importsys
from . importversion_skip
@version_skip
deftest_lazy_imports():
# plotly not imported yet
assert"plotly"notinsys.modules
# Import top-level plotly module
importplotly
assert"plotly"insys.modules
# Check that submodules are not auto-imported, but can be be accessed using
# attribute syntax
submodules= ["graph_objs", "io"]
forminsubmodules:
module_str="plotly."+m
assertmodule_strnotinsys.modules
getattr(plotly, m)
assertmodule_strinsys.modules
# Check that constructing and serializing empty figure doesn't auto-import
# nested graph objects
plotly.graph_objects.Figure().to_json()
submodules= [("layout", "title"), ("scatter", "marker"), ("scattergl", "marker")]
formodule_partsinsubmodules:
module_str="plotly.graph_objs."+".".join(module_parts)
assertmodule_strnotinsys.modules
# Use getattr to
module=plotly.graph_objects
forminmodule_parts:
module=getattr(module, m)
assertmodule_strinsys.modules