X Tutup
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/matplotlib/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from matplotlib.axes import Axes
import matplotlib.pyplot as plt
import numpy as np
import warnings


@cleanup
Expand Down Expand Up @@ -83,7 +84,11 @@ def test_gca():

# the final request for a polar axes will end up creating one
# with a spec of 111.
assert_true(fig.gca(polar=True) is not ax3)
with warnings.catch_warnings(record=True) as w:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within this context, you also need a warnings.simplefilter('always') or else the warning may not be triggered.

warnings.simplefilter('always')
# Changing the projection will throw a warning
assert_true(fig.gca(polar=True) is not ax3)
assert len(w) == 1
assert_true(fig.gca(polar=True) is not ax2)
assert_equal(fig.gca().get_geometry(), (1, 1, 1))

Expand Down Expand Up @@ -133,15 +138,14 @@ def test_alpha():

@cleanup
def test_too_many_figures():
import warnings

with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
for i in range(rcParams['figure.max_open_warning'] + 1):
fig = plt.figure()
assert len(w) == 1


@cleanup
def test_iterability_axes_argument():

# This is a regression test for matplotlib/matplotlib#3196. If one of the
Expand Down
X Tutup