annotate Lib/test/test_structseq.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 95695cc45cdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24364
aa0d2d51fbde Get rid of relative imports in all unittests. Now anything that
Barry Warsaw <barry@python.org>
parents: 22163
diff changeset
1 from test.test_support import vereq
20780
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
2
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
3 import time
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
4
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
5 t = time.gmtime()
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
6 astuple = tuple(t)
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
7 vereq(len(t), len(astuple))
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
8 vereq(t, astuple)
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
9
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
10 # Check that slicing works the same way; at one point, slicing t[i:j] with
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
11 # 0 < i < j could produce NULLs in the result.
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
12 for i in range(-len(t), len(t)):
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
13 for j in range(-len(t), len(t)):
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
14 vereq(t[i:j], astuple[i:j])
ab2e315849a7 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
15
22163
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
16 # Devious code could crash structseqs' contructors
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
17 class C:
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
18 def __getitem__(self, i):
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
19 raise IndexError
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
20 def __len__(self):
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
21 return 9
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
22
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
23 try:
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
24 repr(time.struct_time(C()))
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
25 except:
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
26 pass
42862169541f backport my checkin of
Michael W. Hudson <mwh@python.net>
parents: 20781
diff changeset
27
20781
61226ddadc97 Huh. In an effort to be less thorough <wink>, seems I checked in a new
Tim Peters <tim.peters@gmail.com>
parents: 20780
diff changeset
28 # XXX more needed