[Python-checkins] r54647 - python/trunk/Lib/test/test_strptime.py
brett.cannon
python-checkins at python.org
Sun Apr 1 21:46:23 CEST 2007
Author: brett.cannon
Date: Sun Apr 1 21:46:19 2007
New Revision: 54647
Modified:
python/trunk/Lib/test/test_strptime.py
Log:
Fix the test for recreating the locale cache object by not worrying about if
one of the test locales cannot be set.
Modified: python/trunk/Lib/test/test_strptime.py
==============================================================================
--- python/trunk/Lib/test/test_strptime.py (original)
+++ python/trunk/Lib/test/test_strptime.py Sun Apr 1 21:46:19 2007
@@ -514,11 +514,23 @@
return
try:
_strptime.strptime('10', '%d')
+ # Get id of current cache object.
first_time_re_id = id(_strptime._TimeRE_cache)
- locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8'))
- _strptime.strptime('10', '%d')
- second_time_re_id = id(_strptime._TimeRE_cache)
- self.failIfEqual(first_time_re_id, second_time_re_id)
+ try:
+ # Change the locale and force a recreation of the cache.
+ locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8'))
+ _strptime.strptime('10', '%d')
+ # Get the new cache object's id.
+ second_time_re_id = id(_strptime._TimeRE_cache)
+ # They should not be equal.
+ 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:
locale.setlocale(locale.LC_TIME, locale_info)
More information about the Python-checkins
mailing list