File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1
1
import builtins
2
+ import subprocess
3
+ import sys
2
4
3
5
import matplotlib
4
6
5
7
8
+
6
9
def test_simple ():
7
10
assert 1 + 1 == 2
8
11
@@ -34,3 +37,38 @@ def test_override_builtins():
34
37
35
38
def test_verbose ():
36
39
assert isinstance (matplotlib .verbose , matplotlib .Verbose )
40
+
41
+
42
+ def test_lazy_imports ():
43
+ # The list of modules we want to ensure aren't imported by default
44
+ lazy_modules = [
45
+ 'matplotlib._png' ,
46
+ 'matplotlib._tri' ,
47
+ 'matplotlib._qhull' ,
48
+ 'matplotlib._contour'
49
+ ]
50
+
51
+ # The list of modules to import that shouldn't import any of the
52
+ # lazy_modules
53
+ top_level_modules = [
54
+ 'matplotlib.figure' ,
55
+ 'matplotlib.backend_bases' ,
56
+ 'matplotlib.pyplot'
57
+ ]
58
+
59
+ for top_level_module in top_level_modules :
60
+ lines = [
61
+ "import sys" ,
62
+ "import {}" .format (top_level_module )
63
+ ]
64
+ for lazy_module in lazy_modules :
65
+ lines .append ('assert {!r} not in sys.modules' .format (lazy_module ))
66
+ source = '\n ' .join (lines )
67
+
68
+ print (source )
69
+
70
+ subprocess .check_call ([
71
+ sys .executable ,
72
+ '-c' ,
73
+ source
74
+ ])
You can’t perform that action at this time.
0 commit comments