mirror of
https://github.com/python/cpython.git
synced 2025-11-09 06:01:05 +00:00
Fix the test for recreating the locale cache object by not worrying about if
one of the test locales cannot be set.
This commit is contained in:
parent
c69066501b
commit
c7a2e4656e
1 changed files with 16 additions and 4 deletions
|
|
@ -514,11 +514,23 @@ class CacheTests(unittest.TestCase):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
_strptime.strptime('10', '%d')
|
_strptime.strptime('10', '%d')
|
||||||
|
# Get id of current cache object.
|
||||||
first_time_re_id = id(_strptime._TimeRE_cache)
|
first_time_re_id = id(_strptime._TimeRE_cache)
|
||||||
|
try:
|
||||||
|
# Change the locale and force a recreation of the cache.
|
||||||
locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8'))
|
locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8'))
|
||||||
_strptime.strptime('10', '%d')
|
_strptime.strptime('10', '%d')
|
||||||
|
# Get the new cache object's id.
|
||||||
second_time_re_id = id(_strptime._TimeRE_cache)
|
second_time_re_id = id(_strptime._TimeRE_cache)
|
||||||
|
# They should not be equal.
|
||||||
self.failIfEqual(first_time_re_id, second_time_re_id)
|
self.failIfEqual(first_time_re_id, second_time_re_id)
|
||||||
|
# Possible test locale is not supported while initial locale is.
|
||||||
|
# If this is the case just suppress the exception and fall-through
|
||||||
|
# to the reseting to the original locale.
|
||||||
|
except locale.Error:
|
||||||
|
pass
|
||||||
|
# Make sure we don't trample on the locale setting once we leave the
|
||||||
|
# test.
|
||||||
finally:
|
finally:
|
||||||
locale.setlocale(locale.LC_TIME, locale_info)
|
locale.setlocale(locale.LC_TIME, locale_info)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue