Skip to content

Commit

Permalink
Add test for ShapeFactory plotting method used in the docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefmolin committed May 15, 2023
1 parent 3cb8c90 commit ae6610e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/shapes/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,21 @@ def test_generate_shape_error(self, shape_factory):
"""Test the generate_shape() method on a non-existent shape."""
with pytest.raises(ValueError, match='No such shape'):
_ = shape_factory.generate_shape('does not exist')

@pytest.mark.parametrize('subset', [4, 5, 8, 10, None])
def test_plot_available_shapes(self, shape_factory, monkeypatch, subset):
"""Test the plot_available_shapes() method."""
if subset:
monkeypatch.setattr(
shape_factory,
'AVAILABLE_SHAPES',
shape_factory.AVAILABLE_SHAPES[:subset],
)

axs = shape_factory.plot_available_shapes()
populated_axs = [ax for ax in axs.flatten() if ax.get_figure()]
assert len(populated_axs) == len(shape_factory.AVAILABLE_SHAPES)
assert all([ax.get_xlabel() == ax.get_ylabel() == '' for ax in populated_axs])
assert set(ax.get_title() for ax in populated_axs) == set(
shape_factory.AVAILABLE_SHAPES
)

0 comments on commit ae6610e

Please sign in to comment.