Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5417f2d commit 696b031Copy full SHA for 696b031
5 files changed
lib/matplotlib/tests/test_axes.py
@@ -1677,13 +1677,19 @@ def _as_mpl_axes(self):
1677
ax_via_gca = plt.gca(projection=prj)
1678
assert ax_via_gca is ax
1679
# try getting the axes given a different polar projection
1680
- ax_via_gca = plt.gca(projection=prj2)
+ with pytest.warns(UserWarning) as rec:
1681
+ ax_via_gca = plt.gca(projection=prj2)
1682
+ assert len(rec) == 1
1683
+ assert 'Requested projection is different' in str(rec[0].message)
1684
assert ax_via_gca is not ax
1685
assert ax.get_theta_offset() == 0, ax.get_theta_offset()
1686
assert ax_via_gca.get_theta_offset() == np.pi, \
1687
ax_via_gca.get_theta_offset()
1688
# try getting the axes given an == (not is) polar projection
- ax_via_gca = plt.gca(projection=prj3)
1689
+ with pytest.warns(UserWarning):
1690
+ ax_via_gca = plt.gca(projection=prj3)
1691
1692
1693
1694
plt.close()
1695
lib/matplotlib/tests/test_cbook.py
@@ -29,16 +29,18 @@ def test_is_hashable():
29
30
def test_restrict_dict():
31
d = {'foo': 'bar', 1: 2}
32
- d1 = cbook.restrict_dict(d, ['foo', 1])
33
- assert d1 == d
34
- d2 = cbook.restrict_dict(d, ['bar', 2])
35
- assert d2 == {}
36
- d3 = cbook.restrict_dict(d, {'foo': 1})
37
- assert d3 == {'foo': 'bar'}
38
- d4 = cbook.restrict_dict(d, {})
39
- assert d4 == {}
40
- d5 = cbook.restrict_dict(d, {'foo', 2})
41
- assert d5 == {'foo': 'bar'}
+ with pytest.warns(cbook.deprecation.MatplotlibDeprecationWarning) as rec:
+ d1 = cbook.restrict_dict(d, ['foo', 1])
+ assert d1 == d
+ d2 = cbook.restrict_dict(d, ['bar', 2])
+ assert d2 == {}
+ d3 = cbook.restrict_dict(d, {'foo': 1})
+ assert d3 == {'foo': 'bar'}
+ d4 = cbook.restrict_dict(d, {})
+ assert d4 == {}
+ d5 = cbook.restrict_dict(d, {'foo', 2})
42
+ assert d5 == {'foo': 'bar'}
43
+ assert len(rec) == 5
44
# check that d was not modified
45
assert d == {'foo': 'bar', 1: 2}
46
lib/matplotlib/tests/test_colors.py
@@ -690,7 +690,7 @@ def test_tableau_order():
690
assert list(mcolors.TABLEAU_COLORS.values()) == dflt_cycle
691
692
693
-def test_ndarray_subclass_norm():
+def test_ndarray_subclass_norm(recwarn):
694
# Emulate an ndarray subclass that handles units
695
# which objects when adding or subtracting with other
696
# arrays. See #6622 and #8696
@@ -707,3 +707,11 @@ def __add__(self, other):
707
mcolors.SymLogNorm(3, vmax=5, linscale=1),
708
mcolors.PowerNorm(1)]:
709
assert_array_equal(norm(data.view(MyArray)), norm(data))
710
+ if isinstance(norm, mcolors.PowerNorm):
711
+ assert len(recwarn) == 1
712
+ warn = recwarn.pop(UserWarning)
713
+ assert ('Power-law scaling on negative values is ill-defined'
714
+ in str(warn.message))
715
+ else:
716
+ assert len(recwarn) == 0
717
+ recwarn.clear()
lib/matplotlib/tests/test_dates.py
@@ -96,7 +96,10 @@ def test_too_many_date_ticks():
96
tf = datetime.datetime(2000, 1, 20)
97
fig = plt.figure()
98
ax = fig.add_subplot(1, 1, 1)
99
- ax.set_xlim((t0, tf), auto=True)
100
+ ax.set_xlim((t0, tf), auto=True)
101
102
+ assert 'Attempting to set identical left==right' in str(rec[0].message)
103
ax.plot([], [])
104
ax.xaxis.set_major_locator(mdates.DayLocator())
105
with pytest.raises(RuntimeError):
lib/matplotlib/tests/test_image.py
@@ -603,7 +603,8 @@ def test_load_from_url():
603
604
@image_comparison(baseline_images=['log_scale_image'],
605
remove_text=True)
606
-def test_log_scale_image():
+# The recwarn fixture captures a warning in image_comparison.
607
+def test_log_scale_image(recwarn):
608
Z = np.zeros((10, 10))
609
Z[::2] = 1
610
@@ -615,7 +616,6 @@ def test_log_scale_image():
615
616
ax.set_yscale('log')
617
618
-
619
@image_comparison(baseline_images=['rotate_image'],
620
621
def test_rotate_image():
0 commit comments