Skip to content

Commit 6771a18

Browse files
authored
Merge pull request #7328 from Kojoley/fix-rcparam-unicode-parsing-test
TST: Fixed rcparams `test_Issue_1713` test
2 parents a7e5f6f + 70285e1 commit 6771a18

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/matplotlib/tests/test_rcparams.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
from cycler import cycler, Cycler
1212
import pytest
1313

14+
try:
15+
from unittest import mock
16+
except ImportError:
17+
import mock
1418
import matplotlib as mpl
1519
import matplotlib.pyplot as plt
1620
from matplotlib.tests import assert_str_equal
@@ -210,13 +214,9 @@ def test_legend_colors(color_type, param_dict, target):
210214
def test_Issue_1713():
211215
utf32_be = os.path.join(os.path.dirname(__file__),
212216
'test_utf32_be_rcparams.rc')
213-
old_lang = os.environ.get('LANG', None)
214-
os.environ['LANG'] = 'en_US.UTF-32-BE'
215-
rc = mpl.rc_params_from_file(utf32_be, True)
216-
if old_lang:
217-
os.environ['LANG'] = old_lang
218-
else:
219-
del os.environ['LANG']
217+
import locale
218+
with mock.patch('locale.getpreferredencoding', return_value='UTF-32-BE'):
219+
rc = mpl.rc_params_from_file(utf32_be, True, False)
220220
assert rc.get('timezone') == 'UTC'
221221

222222

0 commit comments

Comments
 (0)