Skip to content

Commit

Permalink
Add tests for Plot.on input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Waskom committed Sep 1, 2021
1 parent 4646ae1 commit df5382c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions seaborn/tests/_core/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ def test_on_figure(self, facet):
assert m.passed_axes == f.axes
assert p._figure is f

@pytest.mark.skipif(
LooseVersion(mpl.__version__) < "3.4", reason="mpl<3.4 does not have SubFigure",
)
@pytest.mark.parametrize("facet", [True, False])
def test_on_subfigure(self, facet):

Expand All @@ -707,6 +710,24 @@ def test_on_subfigure(self, facet):
assert m.passed_axes == sf2.figure.axes[1:]
assert p._figure is sf2.figure

def test_on_type_check(self):

p = Plot()
with pytest.raises(TypeError, match="The `Plot.on`.+<class 'list'>"):
p.on([])

def test_on_axes_with_subplots_error(self):

ax = mpl.figure.Figure().subplots()

p1 = Plot().facet(["a", "b"]).on(ax)
with pytest.raises(RuntimeError, match="Cannot create multiple subplots"):
p1.plot()

p2 = Plot().pair([["a", "b"], ["x", "y"]]).on(ax)
with pytest.raises(RuntimeError, match="Cannot create multiple subplots"):
p2.plot()


class TestFacetInterface:

Expand Down

0 comments on commit df5382c

Please sign in to comment.