|
27 | 27 | validate_int, |
28 | 28 | validate_markevery, |
29 | 29 | validate_stringlist, |
| 30 | + validate_sketch, |
30 | 31 | _validate_linestyle, |
31 | 32 | _listify_validator) |
32 | 33 |
|
@@ -628,3 +629,26 @@ def test_rcparams_legend_loc_from_file(tmpdir, value): |
628 | 629 |
|
629 | 630 | with mpl.rc_context(fname=rc_path): |
630 | 631 | assert mpl.rcParams["legend.loc"] == value |
| 632 | + |
| 633 | + |
| 634 | +@pytest.mark.parametrize("value", [(1, 2, 3), '1, 2, 3', '(1, 2, 3)']) |
| 635 | +def test_validate_sketch(value): |
| 636 | + mpl.rcParams["path.sketch"] = value |
| 637 | + assert mpl.rcParams["path.sketch"] == (1, 2, 3) |
| 638 | + assert validate_sketch(value) == (1, 2, 3) |
| 639 | + |
| 640 | + |
| 641 | +@pytest.mark.parametrize("value", [1, '1', '1 2 3']) |
| 642 | +def test_validate_sketch_error(value): |
| 643 | + with pytest.raises(ValueError, match="scale, length, randomness"): |
| 644 | + validate_sketch(value) |
| 645 | + with pytest.raises(ValueError, match="scale, length, randomness"): |
| 646 | + mpl.rcParams["path.sketch"] = value |
| 647 | + |
| 648 | + |
| 649 | +@pytest.mark.parametrize("value", ['1, 2, 3', '(1,2,3)']) |
| 650 | +def test_rcparams_path_sketch_from_file(tmpdir, value): |
| 651 | + rc_path = tmpdir.join("matplotlibrc") |
| 652 | + rc_path.write(f"path.sketch: {value}") |
| 653 | + with mpl.rc_context(fname=rc_path): |
| 654 | + assert mpl.rcParams["path.sketch"] == (1, 2, 3) |
0 commit comments