[pypy-commit] pypy default: A passing test.
arigo
noreply at buildbot.pypy.org
Sat Sep 3 11:57:49 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r47036:c9c5e66fd236
Date: 2011-09-03 11:57 +0200
http://bitbucket.org/pypy/pypy/changeset/c9c5e66fd236/
Log: A passing test.
diff --git a/pypy/module/sys/test/test_encoding.py b/pypy/module/sys/test/test_encoding.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/sys/test/test_encoding.py
@@ -0,0 +1,30 @@
+import os, py
+from pypy.rlib import rlocale
+from pypy.module.sys.interp_encoding import _getfilesystemencoding
+from pypy.module.sys.interp_encoding import base_encoding
+
+
+def test__getfilesystemencoding(space):
+ if not (rlocale.HAVE_LANGINFO and rlocale.CODESET):
+ py.test.skip("requires HAVE_LANGINFO and CODESET")
+
+ def clear():
+ for key in os.environ.keys():
+ if key == 'LANG' or key.startswith('LC_'):
+ del os.environ[key]
+
+ def get(**env):
+ original_env = os.environ.copy()
+ try:
+ clear()
+ os.environ.update(env)
+ return _getfilesystemencoding(space)
+ finally:
+ clear()
+ os.environ.update(original_env)
+
+ assert get() in (base_encoding, 'ANSI_X3.4-1968')
+ assert get(LANG='foobar') in (base_encoding, 'ANSI_X3.4-1968')
+ assert get(LANG='en_US.UTF-8') == 'UTF-8'
+ assert get(LC_ALL='en_US.UTF-8') == 'UTF-8'
+ assert get(LC_CTYPE='en_US.UTF-8') == 'UTF-8'
More information about the pypy-commit
mailing list