annotate Lib/test/test_strftime.py @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents aa0d2d51fbde
children 63865611ed2f ae8dbf500172
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
16519
631d4c8db784 String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 15966
diff changeset
5 import time, calendar, sys, os, re
24364
aa0d2d51fbde Get rid of relative imports in all unittests. Now anything that
Barry Warsaw <barry@python.org>
parents: 19694
diff changeset
6 from test.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
17216
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
10 # For C Python, these tests expect C locale, so we try to set that
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
11 # explicitly. For Jython, Finn says we need to be in the US locale; my
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
12 # understanding is that this is the closest Java gets to C's "C" locale.
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
13 # Jython ought to supply an _locale module which Does The Right Thing, but
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
14 # this is the best we can do given today's state of affairs.
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
15 try:
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
16 import java
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
17 java.util.Locale.setDefault(java.util.Locale.US)
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
18 except ImportError:
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
19 # Can't do this first because it will succeed, even in Jython
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
20 import locale
a1b99d088cea main(): Application of SF patch #405851, which allows this test to be
Barry Warsaw <barry@python.org>
parents: 16519
diff changeset
21 locale.setlocale(locale.LC_TIME, 'C')
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
22 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
23 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
24 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
25 # 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
26 # 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
27 for j in range(-5, 5):
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
28 for i in range(25):
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
29 strftest(now + (i + j*100)*23*3603)
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 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
32 if verbose:
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
33 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
34 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
35 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
36 now = time.localtime(now)
4697
1f368fb3e1f7 Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
14590
c42105bdb5fc Allow am/pm as well as AM/PM (C9X behaviour).
Jack Jansen <jack.jansen@cwi.nl>
parents: 10544
diff changeset
38 if now[3] < 12: ampm='(AM|am)'
c42105bdb5fc Allow am/pm as well as AM/PM (C9X behaviour).
Jack Jansen <jack.jansen@cwi.nl>
parents: 10544
diff changeset
39 else: ampm='(PM|pm)'
5174
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
40
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
41 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
42
5989
5b90da8a9dcc Fixes for the Mac. (Jack)
Guido van Rossum <guido@python.org>
parents: 5539
diff changeset
43 try:
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
44 if now[8]: tz = time.tzname[1]
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
45 else: tz = time.tzname[0]
5989
5b90da8a9dcc Fixes for the Mac. (Jack)
Guido van Rossum <guido@python.org>
parents: 5539
diff changeset
46 except AttributeError:
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
47 tz = ''
4697
1f368fb3e1f7 Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
48
5174
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
49 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
50 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
51 else: clock12 = 12
4697
1f368fb3e1f7 Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
52
5174
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
53 expectations = (
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
54 ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
55 ('%A', calendar.day_name[now[6]], 'full weekday name'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
56 ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
57 ('%B', calendar.month_name[now[1]], 'full month name'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
58 # %c see below
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
59 ('%d', '%02d' % now[2], 'day of month as number (00-31)'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
60 ('%H', '%02d' % now[3], 'hour (00-23)'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
61 ('%I', '%02d' % clock12, 'hour (01-12)'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
62 ('%j', '%03d' % now[7], 'julian day (001-366)'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
63 ('%m', '%02d' % now[1], 'month as number (01-12)'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
64 ('%M', '%02d' % now[4], 'minute, (00-59)'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
65 ('%p', ampm, 'AM or PM as appropriate'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
66 ('%S', '%02d' % now[5], 'seconds of current time (00-60)'),
19694
3716b116fb31 The first batch of changes recommended by the fixdiv tool. These are
Guido van Rossum <guido@python.org>
parents: 17216
diff changeset
67 ('%U', '%02d' % ((now[7] + jan1[6])//7),
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
68 'week number of the year (Sun 1st)'),
9101
3135316cd670 Patch by Marc-Andre Lemburg: use re module to compare test results.
Guido van Rossum <guido@python.org>
parents: 7747
diff changeset
69 ('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'),
19694
3716b116fb31 The first batch of changes recommended by the fixdiv tool. These are
Guido van Rossum <guido@python.org>
parents: 17216
diff changeset
70 ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)//7),
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
71 'week number of the year (Mon 1st)'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
72 # %x see below
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
73 ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
74 ('%y', '%02d' % (now[0]%100), 'year without century'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
75 ('%Y', '%d' % now[0], 'year with century'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
76 # %Z see below
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
77 ('%%', '%', 'single percent sign'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
78 )
4698
ee98e44d4f85 Fixed test_strftime to be silent when called from autotest.
Guido van Rossum <guido@python.org>
parents: 4697
diff changeset
79
5174
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
80 nonstandard_expectations = (
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
81 # These are standard but don't have predictable output
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
82 ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
83 ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
84 '%m/%d/%y %H:%M:%S'),
9101
3135316cd670 Patch by Marc-Andre Lemburg: use re module to compare test results.
Guido van Rossum <guido@python.org>
parents: 7747
diff changeset
85 ('%Z', '%s' % tz, 'time zone name'),
6047
96fecc80a28f Moved some non-standard format characters out of the standard list.
Guido van Rossum <guido@python.org>
parents: 5989
diff changeset
86
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
87 # These are some platform specific extensions
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
88 ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
89 ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
90 ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
91 ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
92 ('%n', '\n', 'newline character'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
93 ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
94 '%I:%M:%S %p'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
95 ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
96 ('%s', nowsecs, 'seconds since the Epoch in UCT'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
97 ('%t', '\t', 'tab character'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
98 ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
99 ('%3y', '%03d' % (now[0]%100),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
100 'year without century rendered using fieldwidth'),
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
101 )
4697
1f368fb3e1f7 Added test_strftime (Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
102
5174
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
103 if verbose:
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
104 print "Strftime test, platform: %s, Python version: %s" % \
16519
631d4c8db784 String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 15966
diff changeset
105 (sys.platform, sys.version.split()[0])
4768
f7a61c6a65c3 Different operation in verbose mode: show the supported nonstandard
Guido van Rossum <guido@python.org>
parents: 4723
diff changeset
106
5174
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
107 for e in expectations:
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
108 try:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
109 result = time.strftime(e[0], now)
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
110 except ValueError, error:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
111 print "Standard '%s' format gave error:" % e[0], error
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
112 continue
9101
3135316cd670 Patch by Marc-Andre Lemburg: use re module to compare test results.
Guido van Rossum <guido@python.org>
parents: 7747
diff changeset
113 if re.match(e[1], result): continue
10542
edc7b28d9052 On Windows, we suddenly find, strftime() may return "" for an
Guido van Rossum <guido@python.org>
parents: 9101
diff changeset
114 if not result or result[0] == '%':
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
115 print "Does not support standard '%s' format (%s)" % (e[0], e[2])
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
116 else:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
117 print "Conflict for %s (%s):" % (e[0], e[2])
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
118 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
119
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
120 for e in nonstandard_expectations:
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
121 try:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
122 result = time.strftime(e[0], now)
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
123 except ValueError, result:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
124 if verbose:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
125 print "Error for nonstandard '%s' format (%s): %s" % \
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
126 (e[0], e[2], str(result))
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
127 continue
9101
3135316cd670 Patch by Marc-Andre Lemburg: use re module to compare test results.
Guido van Rossum <guido@python.org>
parents: 7747
diff changeset
128 if re.match(e[1], result):
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
129 if verbose:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
130 print "Supports nonstandard '%s' format (%s)" % (e[0], e[2])
10544
3400aa1b0073 # Bah. The same problem occurred a second time.
Guido van Rossum <guido@python.org>
parents: 10542
diff changeset
131 elif not result or result[0] == '%':
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
132 if verbose:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
133 print "Does not appear to support '%s' format (%s)" % (e[0],
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
134 e[2])
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
135 else:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
136 if verbose:
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
137 print "Conflict for nonstandard '%s' format (%s):" % (e[0],
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
138 e[2])
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
139 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
140
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
141 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
142 if s[8] == ' ':
7747
aedd2d0dcb31 Mass check-in after untabifying all files that need it.
Guido van Rossum <guido@python.org>
parents: 6854
diff changeset
143 s = s[:8] + '0' + s[9:]
5174
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
144 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
145
c4e5ef9bc361 Much more rigorous testing -- we now try many times, varying in time
Guido van Rossum <guido@python.org>
parents: 5137
diff changeset
146 main()