mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
convert test_locale to unittest, and add a mechanism to override localconv() results for further testing (#1864, #1222)
This commit is contained in:
parent
5fdfa3e36d
commit
ba54edadb3
2 changed files with 270 additions and 111 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue