Skip to content

Commit 1f794a7

Browse files
committed
Fix test_strptime raises a DeprecationWarning
1 parent 19a2202 commit 1f794a7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Lib/test/test_strptime.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -679,33 +679,33 @@ class CacheTests(unittest.TestCase):
679679
def test_time_re_recreation(self):
680680
# Make sure cache is recreated when current locale does not match what
681681
# cached object was created with.
682-
_strptime._strptime_time("10", "%d")
682+
_strptime._strptime_time("10 2004", "%d %Y")
683683
_strptime._strptime_time("2005", "%Y")
684684
_strptime._TimeRE_cache.locale_time.lang = "Ni"
685685
original_time_re = _strptime._TimeRE_cache
686-
_strptime._strptime_time("10", "%d")
686+
_strptime._strptime_time("10 2004", "%d %Y")
687687
self.assertIsNot(original_time_re, _strptime._TimeRE_cache)
688688
self.assertEqual(len(_strptime._regex_cache), 1)
689689

690690
def test_regex_cleanup(self):
691691
# Make sure cached regexes are discarded when cache becomes "full".
692692
try:
693-
del _strptime._regex_cache['%d']
693+
del _strptime._regex_cache['%d %Y']
694694
except KeyError:
695695
pass
696696
bogus_key = 0
697697
while len(_strptime._regex_cache) <= _strptime._CACHE_MAX_SIZE:
698698
_strptime._regex_cache[bogus_key] = None
699699
bogus_key += 1
700-
_strptime._strptime_time("10", "%d")
700+
_strptime._strptime_time("10 2004", "%d %Y")
701701
self.assertEqual(len(_strptime._regex_cache), 1)
702702

703703
def test_new_localetime(self):
704704
# A new LocaleTime instance should be created when a new TimeRE object
705705
# is created.
706706
locale_time_id = _strptime._TimeRE_cache.locale_time
707707
_strptime._TimeRE_cache.locale_time.lang = "Ni"
708-
_strptime._strptime_time("10", "%d")
708+
_strptime._strptime_time("10 2004", "%d %Y")
709709
self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time)
710710

711711
def test_TimeRE_recreation_locale(self):
@@ -716,13 +716,13 @@ def test_TimeRE_recreation_locale(self):
716716
except locale.Error:
717717
self.skipTest('test needs en_US.UTF8 locale')
718718
try:
719-
_strptime._strptime_time('10', '%d')
719+
_strptime._strptime_time('10 2004', '%d %Y')
720720
# Get id of current cache object.
721721
first_time_re = _strptime._TimeRE_cache
722722
try:
723723
# Change the locale and force a recreation of the cache.
724724
locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8'))
725-
_strptime._strptime_time('10', '%d')
725+
_strptime._strptime_time('10 2004', '%d %Y')
726726
# Get the new cache object's id.
727727
second_time_re = _strptime._TimeRE_cache
728728
# They should not be equal.

0 commit comments

Comments
 (0)