Barry Warsaw | 04f357c | 2002-07-23 19:04:11 +0000 | [diff] [blame] | 1 | from test.test_support import vereq |
Tim Peters | c2fe618 | 2001-10-30 23:20:46 +0000 | [diff] [blame] | 2 | |
| 3 | import time |
| 4 | |
| 5 | t = time.gmtime() |
| 6 | astuple = tuple(t) |
| 7 | vereq(len(t), len(astuple)) |
| 8 | vereq(t, astuple) |
| 9 | |
| 10 | # Check that slicing works the same way; at one point, slicing t[i:j] with |
| 11 | # 0 < i < j could produce NULLs in the result. |
| 12 | for i in range(-len(t), len(t)): |
| 13 | for j in range(-len(t), len(t)): |
| 14 | vereq(t[i:j], astuple[i:j]) |
| 15 | |
Michael W. Hudson | 02b28ec | 2002-03-06 17:18:15 +0000 | [diff] [blame] | 16 | # Devious code could crash structseqs' contructors |
| 17 | class C: |
| 18 | def __getitem__(self, i): |
| 19 | raise IndexError |
| 20 | def __len__(self): |
| 21 | return 9 |
| 22 | |
| 23 | try: |
| 24 | repr(time.struct_time(C())) |
| 25 | except: |
| 26 | pass |
| 27 | |
Tim Peters | 7e0f81e | 2001-10-31 03:46:14 +0000 | [diff] [blame] | 28 | # XXX more needed |