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

Skip to content

Commit 027fac6

Browse files
committed
Add error handling for locale
1 parent b692160 commit 027fac6

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,20 +1449,21 @@ def test_latex(self, is_latex, usetex, expected):
14491449
assert fmt.format_pct(50, 100) == expected
14501450

14511451

1452-
@pytest.mark.xfail(locale != "fy_DE.UTF-8",
1453-
reason="Locale 'fy_DE.UTF-8' is not supported")
1452+
@pytest.mark.xfail
14541453
def test_locale_comma():
14551454
currentLocale = locale.getlocale()
1456-
locale.setlocale(locale.LC_ALL, 'fy_DE.UTF-8')
1457-
ticks = mticker.ScalarFormatter(useMathText=True, useLocale=True)
1458-
fmt = '$\\mathdefault{%1.1f}$'
1459-
x = ticks._format_maybe_minus_and_locale(fmt, 0.5)
1460-
assert x == '$\\mathdefault{0{,}5}$'
1461-
# Do not change , in the format string
1462-
fmt = ',$\\mathdefault{,%1.1f},$'
1463-
x = ticks._format_maybe_minus_and_locale(fmt, 0.5)
1464-
assert x == ',$\\mathdefault{,0{,}5},$'
1465-
locale.setlocale(locale.LC_ALL, currentLocale)
1455+
try:
1456+
locale.setlocale(locale.LC_ALL, 'fy_DE.UTF-8')
1457+
ticks = mticker.ScalarFormatter(useMathText=True, useLocale=True)
1458+
fmt = '$\\mathdefault{%1.1f}$'
1459+
x = ticks._format_maybe_minus_and_locale(fmt, 0.5)
1460+
assert x == '$\\mathdefault{0{,}5}$'
1461+
# Do not change , in the format string
1462+
fmt = ',$\\mathdefault{,%1.1f},$'
1463+
x = ticks._format_maybe_minus_and_locale(fmt, 0.5)
1464+
assert x == ',$\\mathdefault{,0{,}5},$'
1465+
finally:
1466+
locale.setlocale(locale.LC_ALL, currentLocale)
14661467

14671468

14681469
def test_majformatter_type():

0 commit comments

Comments
 (0)