[Python-Dev] RE: test_strptime; test_logging; test_time failure (original) (raw)

Brett C. drifty@alum.berkeley.edu
Wed, 23 Jul 2003 13:04:59 -0700


Tim Peters wrote:

[Brett C.]

I should have been more explicit; I meant after every individual test and not after the battery of tests.

OK, and back to an unpatched strptime.py. With the current CVS locale-restoration code (which differs from what it was half an hour ago, but should have the same effect):

Again, without restoring locale in testlogging: C:\Code\python\PCbuild>python ../lib/test/regrtest.py teststrptime testlogging testtime time.strftime("%c") '07/22/03 20:39:09'

So no AM/PM.

strptime.TimeRE()['c'] '(?P1[0-2]|0[1-9]|[1-9])/(?P3[0-1]|[1-2]\d|0[1-9]| [1-9]| [1-9])/(?P\d\d)\s*(?P2[0-3]|[0-1]\d|\d) :(?P[0-5]\d|\d):(?P6[0-1]|[0-5]\d|\d)'

locale.getdefaultlocale() ('enUS', 'cp1252') locale.getlocale(locale.LCTIME) (None, None)

Note value of here.

teststrptime time.strftime("%c") '07/22/03 20:39:10'

strptime.TimeRE()['c'] '(?P1[0-2]|0[1-9]|[1-9])/(?P3[0-1]|[1-2]\d|0[1-9]| [1-9]| [1-9])/(?P\d\d)\s*(?P2[0-3]|[0-1]\d|\d) :(?P[0-5]\d|\d):(?P6[0-1]|[0-5]\d|\d)' locale.getdefaultlocale() ('enUS', 'cp1252') locale.getlocale(locale.LCTIME) (None, None) testlogging time.strftime("%c") '07/22/2003 08:39:11 PM' strptime.TimeRE()['c'] '(?P1[0-2]|0[1-9]|[1-9])/(?P3[0-1]|[1-2]\d|0[1-9]| [1-9]| [1-9])/(?P\d\d)\s*(?P2[0-3]|[0-1]\d|\d) :(?P[0-5]\d|\d):(?P6[0-1]|[0-5]\d|\d)' locale.getdefaultlocale() ('enUS', 'cp1252') locale.getlocale(locale.LCTIME) ['EnglishUnited States', '1252'] testtime test testtime failed -- Traceback (most recent call last): File "C:\CODE\PYTHON\lib\test\testtime.py", line 49, in teststrptime self.fail('conversion specifier: %r failed.' % format) File "C:\CODE\PYTHON\lib\unittest.py", line 260, in fail raise self.failureException, msg AssertionError: conversion specifier: ' %c' failed. time.strftime("%c") '07/22/2003 08:39:13 PM'

test_logging does its magic and now AM/PM appears.

strptime.TimeRE()['c'] '(?P1[0-2]|0[1-9]|[1-9])/(?P3[0-1]|[1-2]\d|0[1-9]| [1-9]| [1-9])/(?P\d\d)\s*(?P2[0-3]|[0-1]\d|\d) :(?P[0-5]\d|\d):(?P6[0-1]|[0-5]\d|\d)'

locale.getdefaultlocale() ('enUS', 'cp1252') locale.getlocale(locale.LCTIME) ['EnglishUnited States', '1252']

And now locale.getlocale(locale.LC_TIME) returns a different value!

2 tests OK. 1 test failed: testtime

C:\Code\python\PCbuild>

So this should be solvable by changing some comparison code and what is used to represent the language. I will have a look and see if I can figure out where this is going wrong. If I don't have it fixed by the end of today I will rip out the caching code and just leave a fix for 2.3.1 and 2.4 .

-Brett