summaryrefslogtreecommitdiff
path: root/Lib/locale.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2008-07-25 20:40:19 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2008-07-25 20:40:19 +0000
commitba54edadb3ad920a72369374bca35021bb8a1edb (patch)
tree4e3053466e0c0e242e241f5121054a2f84550ab7 /Lib/locale.py
parent5fdfa3e36d08e8627cd57d2f9653e1ec634f8355 (diff)
downloadcpython-git-ba54edadb3ad920a72369374bca35021bb8a1edb.tar.gz
convert test_locale to unittest, and add a mechanism to override localconv() results for further testing (#1864, #1222)
Diffstat (limited to 'Lib/locale.py')
-rw-r--r--Lib/locale.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/locale.py b/Lib/locale.py
index 751353dac2..fd948a793f 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -12,6 +12,7 @@
"""
import sys, encodings, encodings.aliases
+import functools
# Try importing the _locale module.
#
@@ -87,6 +88,21 @@ except ImportError:
"""
return s
+
+_localeconv = localeconv
+
+# With this dict, you can override some items of localeconv's return value.
+# This is useful for testing purposes.
+_override_localeconv = {}
+
+@functools.wraps(_localeconv)
+def localeconv():
+ d = _localeconv()
+ if _override_localeconv:
+ d.update(_override_localeconv)
+ return d
+
+
### Number formatting APIs
# Author: Martin von Loewis