convert test_locale to unittest, and add a mechanism to override localconv() results for further testing (#1864, #1222)
diff --git a/Lib/locale.py b/Lib/locale.py
index 751353d..fd948a7 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 @@
         """
         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