mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Fixed test_strftime to be silent when called from autotest.
This commit is contained in:
parent
483705c5a9
commit
15d1079dd2
2 changed files with 15 additions and 9 deletions
|
@ -1,5 +1 @@
|
||||||
test_strftime
|
test_strftime
|
||||||
Strftime test, platform: irix5, Python version: 1.4
|
|
||||||
Does not appear to support '%k' format
|
|
||||||
Does not appear to support '%s' format
|
|
||||||
Does not appear to support '%3y' format
|
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
import time, calendar, sys, string, os
|
import time, calendar, sys, string, os
|
||||||
|
|
||||||
|
verbose = 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
verbose = 1
|
||||||
|
|
||||||
now = time.time()
|
now = time.time()
|
||||||
fp = os.popen('date')
|
fp = os.popen('date')
|
||||||
fromdate = string.strip(fp.readline())
|
fromdate = string.strip(fp.readline())
|
||||||
|
@ -35,14 +40,12 @@ expectations = (
|
||||||
('%b', calendar.month_abbr[now[1]], 'abbreviated month name'),
|
('%b', calendar.month_abbr[now[1]], 'abbreviated month name'),
|
||||||
('%h', calendar.month_abbr[now[1]], 'abbreviated month name'),
|
('%h', calendar.month_abbr[now[1]], 'abbreviated month name'),
|
||||||
('%c', time.asctime(now), 'asctime() format'),
|
('%c', time.asctime(now), 'asctime() format'),
|
||||||
('%C', fromdate, 'date(1) format'),
|
|
||||||
('%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'),
|
||||||
('%d', '%02d' % now[2], 'day of month as number (00-31)'),
|
('%d', '%02d' % now[2], 'day of month as number (00-31)'),
|
||||||
('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'),
|
('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'),
|
||||||
('%H', '%02d' % now[3], 'hour (00-23)'),
|
('%H', '%02d' % now[3], 'hour (00-23)'),
|
||||||
('%I', '%02d' % clock12, 'hour (00-12)'),
|
('%I', '%02d' % clock12, 'hour (00-12)'),
|
||||||
('%j', '%03d' % now[7], 'julian day (001-366)'),
|
('%j', '%03d' % now[7], 'julian day (001-366)'),
|
||||||
('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'),
|
|
||||||
('%M', '%02d' % now[4], 'minute, (00-59)'),
|
('%M', '%02d' % now[4], 'minute, (00-59)'),
|
||||||
('%m', '%02d' % now[1], 'month as number (01-12)'),
|
('%m', '%02d' % now[1], 'month as number (01-12)'),
|
||||||
('%n', '\n', 'newline character'),
|
('%n', '\n', 'newline character'),
|
||||||
|
@ -52,7 +55,6 @@ expectations = (
|
||||||
'%I:%M:%S %p'),
|
'%I:%M:%S %p'),
|
||||||
('%t', '\t', 'tab character'),
|
('%t', '\t', 'tab character'),
|
||||||
('%S', '%02d' % now[5], 'seconds of current time (00-60)'),
|
('%S', '%02d' % now[5], 'seconds of current time (00-60)'),
|
||||||
('%s', '%d' % nowsecs, 'seconds since the Epoch in UCT'),
|
|
||||||
('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'),
|
('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'),
|
||||||
('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'),
|
('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'),
|
||||||
('%U', '%02d' % (1+(wk1offset+now[7])/7),
|
('%U', '%02d' % (1+(wk1offset+now[7])/7),
|
||||||
|
@ -65,12 +67,20 @@ expectations = (
|
||||||
('%y', '%02d' % (now[0]%100), 'year without century'),
|
('%y', '%02d' % (now[0]%100), 'year without century'),
|
||||||
('%Z', tz, 'time zone name'),
|
('%Z', tz, 'time zone name'),
|
||||||
('%%', '%', 'single percent sign'),
|
('%%', '%', 'single percent sign'),
|
||||||
|
)
|
||||||
|
|
||||||
|
nonstandard_expectations = (
|
||||||
|
('%C', fromdate, 'date(1) format'),
|
||||||
|
('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'),
|
||||||
|
('%s', '%d' % nowsecs, 'seconds since the Epoch in UCT'),
|
||||||
('%3y', '%03d' % (now[0]%100),
|
('%3y', '%03d' % (now[0]%100),
|
||||||
'year without century rendered using fieldwidth'),
|
'year without century rendered using fieldwidth'),
|
||||||
)
|
)
|
||||||
|
|
||||||
print "Strftime test, platform: %s, Python version: %s" % \
|
if verbose:
|
||||||
|
print "Strftime test, platform: %s, Python version: %s" % \
|
||||||
(sys.platform, string.split(sys.version)[0])
|
(sys.platform, string.split(sys.version)[0])
|
||||||
|
expectations = expectations + nonstandard_expectations
|
||||||
|
|
||||||
for e in expectations:
|
for e in expectations:
|
||||||
result = time.strftime(e[0], now)
|
result = time.strftime(e[0], now)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue