Skip to content

Commit

Permalink
Image test for gridline removal
Browse files Browse the repository at this point in the history
  • Loading branch information
rcomer committed Sep 29, 2023
1 parent 44bedc1 commit 6721783
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/cartopy/tests/mpl/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ def pytest_itemcollected(item):
return
elif path.basename == 'tests':
subdir = item.fspath.relto(path)[:-len(item.fspath.ext)]
mpl_marker.kwargs['baseline_dir'] = f'baseline_images/{subdir}'
mpl_marker.kwargs.setdefault('baseline_dir',
f'baseline_images/{subdir}')
break
8 changes: 7 additions & 1 deletion lib/cartopy/tests/mpl/test_gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,17 +454,23 @@ def test_gridliner_count_draws():
mocked.assert_called_once()


@pytest.mark.mpl_image_compare(
baseline_dir='baseline_images/mpl/test_mpl_integration',
filename='simple_global.png')
def test_gridliner_remove():
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
ax.set_global()
ax.coastlines()
gl = ax.gridlines(draw_labels=True)
fig.draw_without_rendering() # Generate child artists
gl.remove()

assert not ax.artists
assert gl not in ax.artists
assert not ax.collections

return fig


def test_gridliner_save_tight_bbox():
# Smoke test for save with auto_update=True and bbox_inches=Tight (gh2246).
Expand Down

0 comments on commit 6721783

Please sign in to comment.