Skip to content

Commit 2e5a310

Browse files
committed
Add tests
1 parent 911632a commit 2e5a310

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/mpl_toolkits/tests/test_axes_grid1.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,9 @@ def test_image_grid():
376376

377377
fig = plt.figure(1, (4, 4))
378378
grid = ImageGrid(fig, 111, nrows_ncols=(2, 2), axes_pad=0.1)
379-
379+
assert grid.get_axes_pad() == (0.1, 0.1)
380380
for i in range(4):
381381
grid[i].imshow(im, interpolation='nearest')
382-
grid[i].set_title('test {0}{0}'.format(i))
383382

384383

385384
def test_gettightbbox():
@@ -492,6 +491,7 @@ def test_grid_axes_lists():
492491
assert_array_equal(grid, grid.axes_all)
493492
assert_array_equal(grid.axes_row, np.transpose(grid.axes_column))
494493
assert_array_equal(grid, np.ravel(grid.axes_row), "row")
494+
assert grid.get_geometry() == (2, 3)
495495
grid = Grid(fig, 111, (2, 3), direction="column")
496496
assert_array_equal(grid, np.ravel(grid.axes_column), "column")
497497

@@ -507,6 +507,17 @@ def test_grid_axes_position(direction):
507507
assert loc[3]._nx == loc[1]._nx and loc[3]._ny == loc[2]._ny
508508

509509

510+
@pytest.mark.parametrize('rect, ngrids, error, message', (
511+
((1, 1), None, TypeError, "Incorrect rect format"),
512+
(111, -1, ValueError, "ngrids must be positive"),
513+
(111, 7, ValueError, "ngrids must be positive"),
514+
))
515+
def test_grid_errors(rect, ngrids, error, message):
516+
fig = plt.figure()
517+
with pytest.raises(error, match=message):
518+
Grid(fig, rect, (2, 3), ngrids=ngrids)
519+
520+
510521
@check_figures_equal(extensions=["png"])
511522
def test_mark_inset_unstales_viewlim(fig_test, fig_ref):
512523
inset, full = fig_test.subplots(1, 2)

0 commit comments

Comments
 (0)