1111
1212import skrub
1313from skrub import datasets
14- from skrub ._data_ops import _inspection
14+ from skrub ._data_ops import _inspection , _utils
1515
1616
17- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
17+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
1818def test_output_dir (tmp_path ):
1919 e = skrub .X ()
2020 assert e .skb .full_report (open = False )["report_path" ].is_relative_to (
@@ -34,7 +34,7 @@ def test_output_dir(tmp_path):
3434 )
3535
3636
37- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
37+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
3838def test_full_report ():
3939 # smoke test for the full report
4040 # TODO we should have a private function that returns the JSON data so we
@@ -60,7 +60,7 @@ def test_full_report():
6060 assert "This step did not run" in (out / "node_4.html" ).read_text ("utf-8" )
6161
6262
63- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
63+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
6464def test_full_report_title ():
6565 # TODO we should have a private function that returns the JSON data so we
6666 # can check the content before rendering with jinja
@@ -71,14 +71,14 @@ def test_full_report_title():
7171 assert title in report ["report_path" ].read_text ("utf-8" )
7272
7373
74- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
74+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
7575def test_preview_subsample ():
7676 X = datasets .fetch_employee_salaries ().X
7777 preview = skrub .X (X ).skb .subsample (n = 3 )._repr_html_ ()
7878 assert "subsample" in preview
7979
8080
81- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
81+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
8282def test_full_report_failed_apply ():
8383 # Somewhat contrived example for the corner case where an Apply does not
8484 # have an easily identifiable estimator.
@@ -96,7 +96,7 @@ def test_full_report_failed_apply():
9696 assert report ["error" ] is not None
9797
9898
99- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
99+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
100100def test_report_fit_mode ():
101101 # non-regression: in fit mode the individual node pages used to show the
102102 # dataop itself as the output instead of the result of fit_transform for
@@ -132,15 +132,15 @@ def test_report_score_mode_with_scoring():
132132 learner .report (environment = {}, mode = "score" )
133133
134134
135- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
135+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
136136def test_full_report_open (monkeypatch ):
137137 mock = Mock ()
138138 monkeypatch .setattr (webbrowser , "open" , mock )
139139 skrub .as_data_op (0 ).skb .full_report ()
140140 mock .assert_called_once ()
141141
142142
143- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
143+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
144144def test_draw_graph ():
145145 g = skrub .as_data_op (0 ).skb .draw_graph ()
146146 assert repr (g ) == "<GraphDrawing: use .open() to display>"
@@ -150,7 +150,7 @@ def test_draw_graph():
150150 assert g ._repr_png_ ().startswith (b"\x89 PNG" )
151151
152152
153- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
153+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
154154def test_svg_anchor_google_colab (monkeypatch ):
155155 """non-regression test for #1589"""
156156 monkeypatch .setitem (sys .modules , "google.colab" , None )
@@ -168,18 +168,18 @@ def _import(name, *args, **kwargs):
168168 return builtin_import (name , * args , ** kwargs )
169169
170170 monkeypatch .setattr (builtins , "__import__" , _import )
171- with pytest .raises (ImportError , match = "Please install pydot " ):
171+ with pytest .raises (RuntimeError , match = "please install Pydot and Graphviz " ):
172172 skrub .as_data_op (0 ).skb .draw_graph ()
173173
174174
175175def test_no_graphviz (monkeypatch ):
176176 pydot = pytest .importorskip ("pydot" )
177177 monkeypatch .setattr (pydot .Dot , "create_svg" , Mock (side_effect = Exception ()))
178- with pytest .raises (ImportError , match = "Please install pydot and graphviz " ):
178+ with pytest .raises (RuntimeError , match = "please install Pydot and Graphviz " ):
179179 skrub .as_data_op (0 ).skb .draw_graph ()
180180
181181
182- @pytest .mark .skipif (not _inspection . _has_graphviz (), reason = "report requires graphviz" )
182+ @pytest .mark .skipif (not _utils . has_graphviz (), reason = "report requires graphviz" )
183183def test_draw_graph_open (monkeypatch ):
184184 mock = Mock ()
185185 monkeypatch .setattr (_inspection , "open_in_browser" , mock )
0 commit comments