irregular6612 Claude Sonnet 4.6 commited on
Commit
8c9f258
·
1 Parent(s): 334147e

test(cp5): guard viz package against eager matplotlib import

Browse files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. tests/viz/test_import_safety.py +17 -0
tests/viz/test_import_safety.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+
4
+ def test_importing_viz_does_not_import_matplotlib():
5
+ # Drop any pre-loaded matplotlib so we observe a fresh import graph.
6
+ for name in list(sys.modules):
7
+ if name == "matplotlib" or name.startswith("matplotlib."):
8
+ del sys.modules[name]
9
+ for name in list(sys.modules):
10
+ if name == "proteus.viz" or name.startswith("proteus.viz."):
11
+ del sys.modules[name]
12
+
13
+ import proteus.viz # noqa: F401
14
+
15
+ assert "matplotlib" not in sys.modules, (
16
+ "importing proteus.viz pulled in matplotlib; keep it lazy in write_pngs"
17
+ )