mirror of
https://github.com/python/cpython.git
synced 2025-09-03 15:31:08 +00:00
gh-53203: Improve tests for strptime() (GH-125090)
Run them with different locales and different date and time. Add the @run_with_locales() decorator to run the test with multiple locales. Improve the run_with_locale() context manager/decorator -- it now catches only expected exceptions and reports the test as skipped if no appropriate locale is available.
This commit is contained in:
parent
7c4b6a68f2
commit
19984fe024
10 changed files with 198 additions and 83 deletions
|
@ -2,7 +2,6 @@ import codecs
|
|||
import contextlib
|
||||
import copy
|
||||
import io
|
||||
import locale
|
||||
import pickle
|
||||
import sys
|
||||
import unittest
|
||||
|
@ -1812,16 +1811,10 @@ class CodecsModuleTest(unittest.TestCase):
|
|||
self.assertRaises(TypeError, codecs.getwriter)
|
||||
self.assertRaises(LookupError, codecs.getwriter, "__spam__")
|
||||
|
||||
@support.run_with_locale('LC_CTYPE', 'tr_TR')
|
||||
def test_lookup_issue1813(self):
|
||||
# Issue #1813: under Turkish locales, lookup of some codecs failed
|
||||
# because 'I' is lowercased as "ı" (dotless i)
|
||||
oldlocale = locale.setlocale(locale.LC_CTYPE)
|
||||
self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
|
||||
try:
|
||||
locale.setlocale(locale.LC_CTYPE, 'tr_TR')
|
||||
except locale.Error:
|
||||
# Unsupported locale on this system
|
||||
self.skipTest('test needs Turkish locale')
|
||||
c = codecs.lookup('ASCII')
|
||||
self.assertEqual(c.name, 'ascii')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue