Skip to content

Commit 43b7976

Browse files
committed
Fix test_RcParams_class on Python 3.15
The `repr` for dictionaries now wraps at the braces. For simplicitly, apply that on older versions as well. Also, shorten the list so it doesn't wrap and need any additional work.
1 parent bfb3875 commit 43b7976

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

lib/matplotlib/tests/test_rcparams.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,32 +73,34 @@ def func():
7373

7474

7575
def test_RcParams_class():
76-
rc = mpl.RcParams({'font.cursive': ['Apple Chancery',
77-
'Textile',
78-
'Zapf Chancery',
79-
'cursive'],
76+
rc = mpl.RcParams({'font.cursive': ['Zapf Chancery', 'cursive'],
8077
'font.family': 'sans-serif',
8178
'font.weight': 'normal',
8279
'font.size': 12})
8380

8481
expected_repr = """
85-
RcParams({'font.cursive': ['Apple Chancery',
86-
'Textile',
87-
'Zapf Chancery',
88-
'cursive'],
82+
RcParams({
83+
'font.cursive': ['Zapf Chancery', 'cursive'],
8984
'font.family': ['sans-serif'],
9085
'font.size': 12.0,
91-
'font.weight': 'normal'})""".lstrip()
86+
'font.weight': 'normal',
87+
})""".lstrip()
9288

93-
assert expected_repr == repr(rc)
89+
actual_repr = repr(rc)
90+
if sys.version_info[:2] < (3, 15):
91+
actual_repr = (actual_repr
92+
.replace("{'", "{\n '")
93+
.replace("'}", "',\n }"))
94+
95+
assert actual_repr == expected_repr
9496

9597
expected_str = """
96-
font.cursive: ['Apple Chancery', 'Textile', 'Zapf Chancery', 'cursive']
98+
font.cursive: ['Zapf Chancery', 'cursive']
9799
font.family: ['sans-serif']
98100
font.size: 12.0
99101
font.weight: normal""".lstrip()
100102

101-
assert expected_str == str(rc)
103+
assert str(rc) == expected_str
102104

103105
# test the find_all functionality
104106
assert ['font.cursive', 'font.size'] == sorted(rc.find_all('i[vz]'))

0 commit comments

Comments
 (0)