|
4 | 4 | from matplotlib.cbook import MatplotlibDeprecationWarning
|
5 | 5 | import matplotlib.pyplot as plt
|
6 | 6 | import numpy as np
|
7 |
| -from numpy.testing import assert_raises |
| 7 | +import pytest |
8 | 8 |
|
9 | 9 | from cycler import cycler
|
10 | 10 |
|
@@ -198,18 +198,28 @@ def test_cycle_reset():
|
198 | 198 | @cleanup
|
199 | 199 | def test_invalid_input_forms():
|
200 | 200 | fig, ax = plt.subplots()
|
201 |
| - assert_raises((TypeError, ValueError), ax.set_prop_cycle, 1) |
202 |
| - assert_raises((TypeError, ValueError), ax.set_prop_cycle, [1, 2]) |
203 |
| - assert_raises((TypeError, ValueError), ax.set_prop_cycle, 'color', 'fish') |
204 |
| - assert_raises((TypeError, ValueError), ax.set_prop_cycle, 'linewidth', 1) |
205 |
| - assert_raises((TypeError, ValueError), ax.set_prop_cycle, |
206 |
| - 'linewidth', {'1': 1, '2': 2}) |
207 |
| - assert_raises((TypeError, ValueError), ax.set_prop_cycle, |
208 |
| - linewidth=1, color='r') |
209 |
| - assert_raises((TypeError, ValueError), ax.set_prop_cycle, 'foobar', [1, 2]) |
210 |
| - assert_raises((TypeError, ValueError), ax.set_prop_cycle, |
211 |
| - foobar=[1, 2]) |
212 |
| - assert_raises((TypeError, ValueError), ax.set_prop_cycle, |
213 |
| - cycler(foobar=[1, 2])) |
214 |
| - assert_raises(ValueError, ax.set_prop_cycle, |
215 |
| - cycler(color='rgb', c='cmy')) |
| 201 | + |
| 202 | + with pytest.raises((TypeError, ValueError)): |
| 203 | + ax.set_prop_cycle(1) |
| 204 | + with pytest.raises((TypeError, ValueError)): |
| 205 | + ax.set_prop_cycle([1, 2]) |
| 206 | + |
| 207 | + with pytest.raises((TypeError, ValueError)): |
| 208 | + ax.set_prop_cycle('color', 'fish') |
| 209 | + |
| 210 | + with pytest.raises((TypeError, ValueError)): |
| 211 | + ax.set_prop_cycle('linewidth', 1) |
| 212 | + with pytest.raises((TypeError, ValueError)): |
| 213 | + ax.set_prop_cycle('linewidth', {'1': 1, '2': 2}) |
| 214 | + with pytest.raises((TypeError, ValueError)): |
| 215 | + ax.set_prop_cycle(linewidth=1, color='r') |
| 216 | + |
| 217 | + with pytest.raises((TypeError, ValueError)): |
| 218 | + ax.set_prop_cycle('foobar', [1, 2]) |
| 219 | + with pytest.raises((TypeError, ValueError)): |
| 220 | + ax.set_prop_cycle(foobar=[1, 2]) |
| 221 | + |
| 222 | + with pytest.raises((TypeError, ValueError)): |
| 223 | + ax.set_prop_cycle(cycler(foobar=[1, 2])) |
| 224 | + with pytest.raises(ValueError): |
| 225 | + ax.set_prop_cycle(cycler(color='rgb', c='cmy')) |
0 commit comments