Patch by Marc-Andre Lemburg: use re module to compare test results.
This makes it possible to accept that on Linux %w returns "01" instead of "1", for example.
This commit is contained in:
parent
09eea82005
commit
7944ea523e
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Sanity checker for time.strftime
|
# Sanity checker for time.strftime
|
||||||
|
|
||||||
import time, calendar, sys, string, os
|
import time, calendar, sys, string, os, re
|
||||||
from test_support import verbose
|
from test_support import verbose
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -54,7 +54,7 @@ def strftest(now):
|
||||||
('%S', '%02d' % now[5], 'seconds of current time (00-60)'),
|
('%S', '%02d' % now[5], 'seconds of current time (00-60)'),
|
||||||
('%U', '%02d' % ((now[7] + jan1[6])/7),
|
('%U', '%02d' % ((now[7] + jan1[6])/7),
|
||||||
'week number of the year (Sun 1st)'),
|
'week number of the year (Sun 1st)'),
|
||||||
('%w', '%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'),
|
('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'),
|
||||||
('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7),
|
('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7),
|
||||||
'week number of the year (Mon 1st)'),
|
'week number of the year (Mon 1st)'),
|
||||||
# %x see below
|
# %x see below
|
||||||
|
@ -70,7 +70,7 @@ def strftest(now):
|
||||||
('%c', fixasctime(time.asctime(now)), 'near-asctime() format'),
|
('%c', fixasctime(time.asctime(now)), 'near-asctime() format'),
|
||||||
('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)),
|
('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)),
|
||||||
'%m/%d/%y %H:%M:%S'),
|
'%m/%d/%y %H:%M:%S'),
|
||||||
('(%Z)', '(%s)' % tz, 'time zone name'),
|
('%Z', '%s' % tz, 'time zone name'),
|
||||||
|
|
||||||
# These are some platform specific extensions
|
# These are some platform specific extensions
|
||||||
('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'),
|
('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'),
|
||||||
|
@ -98,7 +98,7 @@ def strftest(now):
|
||||||
except ValueError, error:
|
except ValueError, error:
|
||||||
print "Standard '%s' format gave error:" % e[0], error
|
print "Standard '%s' format gave error:" % e[0], error
|
||||||
continue
|
continue
|
||||||
if result == e[1]: continue
|
if re.match(e[1], result): continue
|
||||||
if result[0] == '%':
|
if result[0] == '%':
|
||||||
print "Does not support standard '%s' format (%s)" % (e[0], e[2])
|
print "Does not support standard '%s' format (%s)" % (e[0], e[2])
|
||||||
else:
|
else:
|
||||||
|
@ -113,7 +113,7 @@ def strftest(now):
|
||||||
print "Error for nonstandard '%s' format (%s): %s" % \
|
print "Error for nonstandard '%s' format (%s): %s" % \
|
||||||
(e[0], e[2], str(result))
|
(e[0], e[2], str(result))
|
||||||
continue
|
continue
|
||||||
if result == e[1]:
|
if re.match(e[1], result):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Supports nonstandard '%s' format (%s)" % (e[0], e[2])
|
print "Supports nonstandard '%s' format (%s)" % (e[0], e[2])
|
||||||
elif result[0] == '%':
|
elif result[0] == '%':
|
||||||
|
|
Loading…
Reference in New Issue