Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f7622b6

Browse files
committed
Test the rcParams deprecation machinery.
1 parent 8ce14fb commit f7622b6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

lib/matplotlib/tests/test_rcparams.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,3 +508,39 @@ def test_backend_fallback_headful(tmpdir):
508508
# The actual backend will depend on what's installed, but at least tkagg is
509509
# present.
510510
assert backend.strip().lower() != "agg"
511+
512+
513+
def test_deprecation(monkeypatch):
514+
monkeypatch.setitem(
515+
mpl._deprecated_map, "patch.linewidth",
516+
("0.0", "axes.linewidth", lambda old: 2 * old, lambda new: new / 2))
517+
with pytest.warns(_api.MatplotlibDeprecationWarning):
518+
assert mpl.rcParams["patch.linewidth"] \
519+
== mpl.rcParams["axes.linewidth"] / 2
520+
with pytest.warns(_api.MatplotlibDeprecationWarning):
521+
mpl.rcParams["patch.linewidth"] = 1
522+
assert mpl.rcParams["axes.linewidth"] == 2
523+
524+
monkeypatch.setitem(
525+
mpl._deprecated_ignore_map, "patch.edgecolor",
526+
("0.0", "axes.edgecolor"))
527+
with pytest.warns(_api.MatplotlibDeprecationWarning):
528+
assert mpl.rcParams["patch.edgecolor"] \
529+
== mpl.rcParams["axes.edgecolor"]
530+
with pytest.warns(_api.MatplotlibDeprecationWarning):
531+
mpl.rcParams["patch.edgecolor"] = "#abcd"
532+
assert mpl.rcParams["axes.edgecolor"] != "#abcd"
533+
534+
monkeypatch.setitem(
535+
mpl._deprecated_ignore_map, "patch.force_edgecolor",
536+
("0.0", None))
537+
with pytest.warns(_api.MatplotlibDeprecationWarning):
538+
assert mpl.rcParams["patch.force_edgecolor"] is None
539+
540+
monkeypatch.setitem(
541+
mpl._deprecated_remain_as_none, "svg.hashsalt",
542+
("0.0",))
543+
with pytest.warns(_api.MatplotlibDeprecationWarning):
544+
mpl.rcParams["svg.hashsalt"] = "foobar"
545+
assert mpl.rcParams["svg.hashsalt"] == "foobar" # Doesn't warn.
546+
mpl.rcParams["svg.hashsalt"] = None # Doesn't warn.

0 commit comments

Comments
 (0)