|
1 | 1 | from contextlib import nullcontext |
2 | | -import re |
3 | 2 | import itertools |
| 3 | +import locale |
| 4 | +import re |
4 | 5 |
|
5 | 6 | import numpy as np |
6 | 7 | from numpy.testing import assert_almost_equal, assert_array_equal |
@@ -546,6 +547,21 @@ def test_use_offset(self, use_offset): |
546 | 547 | tmp_form = mticker.ScalarFormatter() |
547 | 548 | assert use_offset == tmp_form.get_useOffset() |
548 | 549 |
|
| 550 | + def test_use_locale(self): |
| 551 | + conv = locale.localeconv() |
| 552 | + sep = conv['thousands_sep'] |
| 553 | + if not sep or conv['grouping'][-1:] in ([], [locale.CHAR_MAX]): |
| 554 | + pytest.skip('Locale does not apply grouping') # pragma: no cover |
| 555 | + |
| 556 | + with mpl.rc_context({'axes.formatter.use_locale': True}): |
| 557 | + tmp_form = mticker.ScalarFormatter() |
| 558 | + assert tmp_form.get_useLocale() |
| 559 | + |
| 560 | + tmp_form.create_dummy_axis() |
| 561 | + tmp_form.set_bounds(0, 10) |
| 562 | + tmp_form.set_locs([1, 2, 3]) |
| 563 | + assert sep in tmp_form(1e9) |
| 564 | + |
549 | 565 | @pytest.mark.parametrize( |
550 | 566 | 'sci_type, scilimits, lim, orderOfMag, fewticks', scilimits_data) |
551 | 567 | def test_scilimits(self, sci_type, scilimits, lim, orderOfMag, fewticks): |
|
0 commit comments