1+ import warnings
12from unittest .mock import patch
23
34import matplotlib
45import matplotlib .pyplot as plt
6+ import pytest
57import scanpy as sc
68from matplotlib .figure import Figure
79from spatialdata import SpatialData
810
911import spatialdata_plot # noqa: F401
10- from spatialdata_plot ._logging import logger , logger_no_warns , logger_warns
1112from tests .conftest import DPI , PlotTester , PlotTesterMeta
1213
1314sc .pl .set_rcParams_defaults ()
@@ -27,6 +28,15 @@ class TestShow(PlotTester, metaclass=PlotTesterMeta):
2728 def test_plot_pad_extent_adds_padding (self , sdata_blobs : SpatialData ):
2829 sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (pad_extent = 100 )
2930
31+ def test_plot_frameon_false_single_panel (self , sdata_blobs : SpatialData ):
32+ """Visual test: frameon=False hides axes decorations on a single panel (regression for #204)."""
33+ sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (frameon = False )
34+
35+ def test_plot_frameon_false_multi_panel (self , get_sdata_with_multiple_images ):
36+ """Visual test: frameon=False hides axes decorations on all panels (regression for #204)."""
37+ sdata = get_sdata_with_multiple_images ("two" )
38+ sdata .pl .render_images ().pl .show (frameon = False )
39+
3040 def test_no_plt_show_when_ax_provided (self , sdata_blobs : SpatialData ):
3141 """plt.show() must not be called when the user supplies ax= (regression for #362)."""
3242 _ , ax = plt .subplots ()
@@ -62,26 +72,28 @@ def test_title_empty_string_suppresses_title(self, sdata_blobs: SpatialData):
6272 plt .close ("all" )
6373
6474
65- def test_fig_parameter_emits_deprecation_warning (sdata_blobs : SpatialData , caplog ):
66- """Passing fig= should emit a deprecation warning (regression for #204)."""
75+ def test_fig_parameter_emits_deprecation_warning (sdata_blobs : SpatialData ):
76+ """Passing fig= should emit a DeprecationWarning (regression for #204)."""
6777 fig = Figure ()
68- with logger_warns ( caplog , logger , match = "The `fig` parameter is deprecated" ):
78+ with pytest . warns ( DeprecationWarning , match = "`fig` is being deprecated" ):
6979 sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (fig = fig , show = False )
7080 plt .close ("all" )
7181
7282
73- def test_fig_parameter_default_no_warning (sdata_blobs : SpatialData , caplog ):
83+ def test_fig_parameter_default_no_warning (sdata_blobs : SpatialData ):
7484 """Not passing fig= should not emit a deprecation warning."""
75- with logger_no_warns (caplog , logger , match = "The `fig` parameter is deprecated" ):
85+ with warnings .catch_warnings ():
86+ warnings .simplefilter ("error" , DeprecationWarning )
7687 sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (show = False )
7788 plt .close ("all" )
7889
7990
80- def test_fig_parameter_no_warning_with_ax_list (get_sdata_with_multiple_images , caplog ):
91+ def test_fig_parameter_no_warning_with_ax_list (get_sdata_with_multiple_images ):
8192 """Passing fig= with a list of axes should not warn (fig is still required there)."""
8293 sdata = get_sdata_with_multiple_images ("two" )
8394 fig , axs = plt .subplots (1 , 2 )
84- with logger_no_warns (caplog , logger , match = "The `fig` parameter is deprecated" ):
95+ with warnings .catch_warnings ():
96+ warnings .simplefilter ("error" , DeprecationWarning )
8597 sdata .pl .render_images ().pl .show (fig = fig , ax = list (axs ), show = False )
8698 plt .close ("all" )
8799
0 commit comments