Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_strftime.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 8f871a030b8d |
| children | 5b90da8a9dcc |
| rev | line source |
|---|---|
|
4697
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 #! /usr/bin/env python |
|
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 # Sanity checker for time.strftime |
|
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 import time, calendar, sys, string, os |
|
4793
aabf4a03a4b0
Import verbose flag from test_support instead of testing __name__.
Guido van Rossum <guido@python.org>
parents:
4768
diff
changeset
|
6 from test_support import verbose |
|
4698
ee98e44d4f85
Fixed test_strftime to be silent when called from autotest.
Guido van Rossum <guido@python.org>
parents:
4697
diff
changeset
|
7 |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
8 def main(): |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
9 global verbose |
|
4722
c07e5c455576
Hmm, now that I think about it, we *can* use time.time() and 'date' if
Barry Warsaw <barry@python.org>
parents:
4721
diff
changeset
|
10 now = time.time() |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
11 strftest(now) |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
12 verbose = 0 |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
13 # Try a bunch of dates and times, chosen to vary through time of |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
14 # day and daylight saving time |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
15 for j in range(-5, 5): |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
16 for i in range(25): |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
17 strftest(now + (i + j*100)*23*3603) |
|
4697
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
19 def strftest(now): |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
20 if verbose: |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
21 print "strftime test for", time.ctime(now) |
|
5539
8f871a030b8d
Changes to make these tests work on the Mac.
Guido van Rossum <guido@python.org>
parents:
5524
diff
changeset
|
22 nowsecs = str(long(now))[:-1] |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
23 gmt = time.gmtime(now) |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
24 now = time.localtime(now) |
|
4697
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
26 if now[3] < 12: ampm='AM' |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
27 else: ampm='PM' |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
28 |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
29 jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6)) |
|
4697
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
31 if now[8]: tz = time.tzname[1] |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
32 else: tz = time.tzname[0] |
|
4697
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
34 if now[3] > 12: clock12 = now[3] - 12 |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
35 elif now[3] > 0: clock12 = now[3] |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
36 else: clock12 = 12 |
|
4697
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
38 expectations = ( |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
39 ('%A', calendar.day_name[now[6]], 'full weekday name'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
40 ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
41 ('%B', calendar.month_name[now[1]], 'full month name'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
42 ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
43 ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
44 ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
45 ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
46 ('%d', '%02d' % now[2], 'day of month as number (00-31)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
47 ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
48 ('%H', '%02d' % now[3], 'hour (00-23)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
49 ('%I', '%02d' % clock12, 'hour (01-12)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
50 ('%j', '%03d' % now[7], 'julian day (001-366)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
51 ('%M', '%02d' % now[4], 'minute, (00-59)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
52 ('%m', '%02d' % now[1], 'month as number (01-12)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
53 ('%p', ampm, 'AM or PM as appropriate'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
54 ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
55 ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
56 '%I:%M:%S %p'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
57 ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
58 ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
59 ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
60 ('%U', '%02d' % ((now[7] + jan1[6])/7), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
61 'week number of the year (Sun 1st)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
62 ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
63 'week number of the year (Mon 1st)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
64 ('%w', '%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
65 ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
66 '%m/%d/%y %H:%M:%S'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
67 ('%Y', '%d' % now[0], 'year with century'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
68 ('%y', '%02d' % (now[0]%100), 'year without century'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
69 ('%Z', tz, 'time zone name'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
70 ('%%', '%', 'single percent sign'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
71 ) |
|
4698
ee98e44d4f85
Fixed test_strftime to be silent when called from autotest.
Guido van Rossum <guido@python.org>
parents:
4697
diff
changeset
|
72 |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
73 nonstandard_expectations = ( |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
74 ('%C', '%02d' % (now[0]/100), 'century'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
75 # This is for IRIX; on Solaris, %C yields date(1) format. |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
76 # Tough. |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
77 ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), |
|
5539
8f871a030b8d
Changes to make these tests work on the Mac.
Guido van Rossum <guido@python.org>
parents:
5524
diff
changeset
|
78 ('%s', nowsecs, 'seconds since the Epoch in UCT'), |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
79 ('%3y', '%03d' % (now[0]%100), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
80 'year without century rendered using fieldwidth'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
81 ('%n', '\n', 'newline character'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
82 ('%t', '\t', 'tab character'), |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
83 ) |
|
4697
1f368fb3e1f7
Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
85 if verbose: |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
86 print "Strftime test, platform: %s, Python version: %s" % \ |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
87 (sys.platform, string.split(sys.version)[0]) |
|
4768
f7a61c6a65c3
Different operation in verbose mode: show the supported nonstandard
Guido van Rossum <guido@python.org>
parents:
4723
diff
changeset
|
88 |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
89 for e in expectations: |
|
5321
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
90 try: |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
91 result = time.strftime(e[0], now) |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
92 except ValueError, error: |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
93 print "Standard '%s' format gave error:" % e[0], error |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
94 continue |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
95 if result == e[1]: continue |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
96 if result[0] == '%': |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
97 print "Does not support standard '%s' format (%s)" % (e[0], e[2]) |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
98 else: |
|
4768
f7a61c6a65c3
Different operation in verbose mode: show the supported nonstandard
Guido van Rossum <guido@python.org>
parents:
4723
diff
changeset
|
99 print "Conflict for %s (%s):" % (e[0], e[2]) |
|
f7a61c6a65c3
Different operation in verbose mode: show the supported nonstandard
Guido van Rossum <guido@python.org>
parents:
4723
diff
changeset
|
100 print " Expected %s, but got %s" % (e[1], result) |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
101 |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
102 for e in nonstandard_expectations: |
|
5321
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
103 try: |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
104 result = time.strftime(e[0], now) |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
105 except ValueError, result: |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
106 if verbose: |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
107 print "Error for nonstandard '%s' format (%s): %s" % \ |
|
5524
9a237a4cf3a1
Fix typo in error reporting.
Guido van Rossum <guido@python.org>
parents:
5321
diff
changeset
|
108 (e[0], e[2], str(result)) |
|
5321
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
109 continue |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
110 if result == e[1]: |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
111 if verbose: |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
112 print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
113 elif result[0] == '%': |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
114 if verbose: |
|
5321
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
115 print "Does not appear to support '%s' format (%s)" % (e[0], |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
116 e[2]) |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
117 else: |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
118 if verbose: |
|
5321
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
119 print "Conflict for nonstandard '%s' format (%s):" % (e[0], |
|
e2ac0982cc32
Catch and report ValueError raised by strftime.
Guido van Rossum <guido@python.org>
parents:
5174
diff
changeset
|
120 e[2]) |
|
5174
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
121 print " Expected %s, but got %s" % (e[1], result) |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
122 |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
123 def fixasctime(s): |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
124 if s[8] == ' ': |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
125 s = s[:8] + '0' + s[9:] |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
126 return s |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
127 |
|
c4e5ef9bc361
Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents:
5137
diff
changeset
|
128 main() |
