diff options
author | Brett Cannon <bcannon@gmail.com> | 2007-04-01 19:46:19 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2007-04-01 19:46:19 (GMT) |
commit | c7a2e4656e09cebd36a4ad2439794a48b9565737 (patch) | |
tree | 169f73b923ebd438a4972ea485d24235c9d7ed55 /Lib/test | |
parent | c69066501bc2da4aa325833c76e6cf12b87aafa6 (diff) | |
download | cpython-c7a2e4656e09cebd36a4ad2439794a48b9565737.zip cpython-c7a2e4656e09cebd36a4ad2439794a48b9565737.tar.gz cpython-c7a2e4656e09cebd36a4ad2439794a48b9565737.tar.bz2 |
Fix the test for recreating the locale cache object by not worrying about if
one of the test locales cannot be set.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_strptime.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 48e6b31..f474752 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -514,11 +514,23 @@ class CacheTests(unittest.TestCase): 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) |