8000 Merge pull request #7328 from Kojoley/fix-rcparam-unicode-parsing-test · matplotlib/matplotlib@6dbbb98 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6dbbb98

Browse files
tacaswellQuLogic
authored andcommitted
Merge pull request #7328 from Kojoley/fix-rcparam-unicode-parsing-test
TST: Fixed rcparams `test_Issue_1713` test
1 parent 58cc83d commit 6dbbb98

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
@@ -10,6 +10,10 @@
1010

1111
from cycler import cycler, Cycler
1212

13+
try:
14+
from unittest import mock
15+
except ImportError:
16+
import mock
1317
import matplotlib as mpl
1418
import matplotlib.pyplot as plt
1519
from matplotlib.tests import assert_str_equal
@@ -212,13 +216,9 @@ def test_legend_edgecolor():
212216
def test_Issue_1713():
213217
utf32_be = os.path.join(os.path.dirname(__file__),
214218
'test_utf32_be_rcparams.rc')
215-
old_lang = os.environ.get('LANG', None)
216-
os.environ['LANG'] = 'en_US.UTF-32-BE'
217-
rc = mpl.rc_params_from_file(utf32_be, True)
218-
if old_lang:
219-
os.environ['LANG'] = old_lang
220-
else:
221-
del os.environ['LANG']
219+
import locale
220+
with mock.patch('locale.getpreferredencoding', return_value='UTF-32-BE'):
221+
rc = mpl.rc_params_from_file(utf32_be, True, False)
222222
assert rc.get('timezone') == 'UTC'
223223

224224

0 commit comments

Comments
 (0)
0