1 from test
.test_support
import TestFailed
, verbose
7 def __getitem__(self
, i
):
8 if i
>= 0 and i
< 3: return i
19 if a
!= 1 or b
!= 2 or c
!= 3:
26 if a
!= 4 or b
!= 5 or c
!= 6:
29 # unpack implied tuple
31 print 'unpack implied tuple'
33 if a
!= 7 or b
!= 8 or c
!= 9:
36 # unpack string... fun!
40 if a
!= 'o' or b
!= 'n' or c
!= 'e':
43 # unpack generic sequence
45 print 'unpack sequence'
47 if a
!= 0 or b
!= 1 or c
!= 2:
50 # single element unpacking, with extra syntax
52 print 'unpack single tuple/list'
62 # now for some failures
64 # unpacking non-sequence
66 print 'unpack non-sequence'
74 # unpacking tuple of wrong size
76 print 'unpack tuple wrong size'
83 # unpacking list of wrong size
85 print 'unpack list wrong size'
93 # unpacking sequence too short
95 print 'unpack sequence too short'
103 # unpacking sequence too long
105 print 'unpack sequence too long'
113 # unpacking a sequence where the test for too long raises a different
115 class BozoError(Exception):
119 def __getitem__(self
, i
):
128 # trigger code while not expecting an IndexError
130 print 'unpack sequence too long, wrong error'
132 a
, b
, c
, d
, e
= BadSeq()
137 # trigger code while expecting an IndexError
139 print 'unpack sequence too short, wrong error'