8000 fix test for relaxed warning condition · matplotlib/matplotlib@fb9ad65 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb9ad65

Browse files
committed
fix test for relaxed warning condition
1 parent 530ac3d commit fb9ad65

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/matplotlib/tests/test_units.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from matplotlib.testing.decorators import check_figures_equal, image_comparison
77
import matplotlib.units as munits
88
from matplotlib.category import StrCategoryConverter, UnitData
9+
from matplotlib.dates import DateConverter
910
import numpy as np
1011
import pytest
1112

@@ -240,6 +241,7 @@ def test_explicit_converter():
240241
d1 = {"a": 1, "b": 2}
241242
str_cat_converter = StrCategoryConverter()
242243
str_cat_converter_2 = StrCategoryConverter()
244+
date_converter = DateConverter()
243245

244246
# Explicit is set
245247
fig1, ax1 = plt.subplots()
@@ -254,12 +256,18 @@ def test_explicit_converter():
254256
with pytest.raises(RuntimeError):
255257
ax1.xaxis.set_converter(str_cat_converter_2)
256258

257-
# Warn when implicit overridden
258259
fig2, ax2 = plt.subplots()
259260
ax2.plot(d1.keys(), d1.values())
260261

262+
# No error when equivalent type is used
263+
ax2.xaxis.set_converter(str_cat_converter)
264+
265+
fig3, ax3 = plt.subplots()
266+
ax3.plot(d1.keys(), d1.values())
267+
268+
# Warn when implicit overridden
261269
with pytest.warns():
262-
ax2.xaxis.set_converter(str_cat_converter)
270+
ax3.xaxis.set_converter(date_converter)
263271

264272

265273
def test_empty_default_limits(quantity_converter):

0 commit comments

Comments
 (0)
0