| 1 | import os, py |
| 2 | from pypy.module.sys.interp_encoding import _getfilesystemencoding |
| 3 | from pypy.module.sys.interp_encoding import base_encoding |
| 4 | |
| 5 | |
| 6 | def test__getfilesystemencoding(space): |
| 7 | assert _getfilesystemencoding(space) == base_encoding |
| 8 | |
| 9 | |
| 10 | def test__getfilesystemencoding_does_not_coerce_locale(space): |
| 11 | """_getfilesystemencoding must not modify LC_CTYPE as a side effect. |
| 12 | |
| 13 | Previously it coerced LC_CTYPE from 'C'/'POSIX' to 'en_US.UTF-8', which |
| 14 | caused app_main.py's POSIX locale detection (for utf8_mode) to miss the |
| 15 | 'C' locale and set utf8_mode=0 instead of 1. |
| 16 | """ |
| 17 | from rpython.rlib import rlocale |
| 18 | if not rlocale.HAVE_LANGINFO: |
| 19 | py.test.skip("requires HAVE_LANGINFO") |
| 20 | original = rlocale.setlocale(rlocale.LC_CTYPE, None) |
| 21 | try: |
| 22 | rlocale.setlocale(rlocale.LC_CTYPE, "C") |
| 23 | _getfilesystemencoding(space) |
| 24 | assert rlocale.setlocale(rlocale.LC_CTYPE, None) == "C" |
| 25 | finally: |
| 26 | rlocale.setlocale(rlocale.LC_CTYPE, original) |