Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5eaf457

Browse files
committed
Different operation in verbose mode: show the supported nonstandard
options. Also added two: %n and %t (newline and tab character).
1 parent af82a7e commit 5eaf457

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

Lib/test/test_strftime.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,32 @@
8080
('%s', '%d' % nowsecs, 'seconds since the Epoch in UCT'),
8181
('%3y', '%03d' % (now[0]%100),
8282
'year without century rendered using fieldwidth'),
83+
('%n', '\n', 'newline character'),
84+
('%t', '\t', 'tab character'),
8385
)
8486

8587
if verbose:
8688
print "Strftime test, platform: %s, Python version: %s" % \
8789
(sys.platform, string.split(sys.version)[0])
88-
expectations = expectations + nonstandard_expectations
8990

9091
for e in expectations:
9192
result = time.strftime(e[0], now)
9293
if result == e[1]: continue
9394
if result[0] == '%':
94-
print "Does not appear to support '%s' format" % e[0]
95+
print "Does not support standard '%s' format (%s)" % (e[0], e[2])
9596
else:
9697
print "Conflict for %s (%s):" % (e[0], e[2])
9798
print " Expected %s, but got %s" % (e[1], result)
99+
100+
for e in nonstandard_expectations:
101+
result = time.strftime(e[0], now)
102+
if result == e[1]:
103+
if verbose:
104+
print "Supports nonstandard '%s' format (%s)" % (e[0], e[2])
105+
elif result[0] == '%':
106+
if verbose:
107+
print "Does not appear to support '%s' format" % e[0]
108+
else:
109+
if verbose:
110+
print "Conflict for %s (%s):" % (e[0], e[2])
111+
print " Expected %s, but got %s" % (e[1], result)

0 commit comments

Comments
 (0)