File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,18 @@ def __init__(self, *args):
55
55
self ._step = step
56
56
self ._len = (stop - start ) // step + bool ((stop - start ) % step )
57
57
58
+ @property
59
+ def start (self ):
60
+ return self ._start
61
+
62
+ @property
63
+ def stop (self ):
64
+ return self ._stop
65
+
66
+ @property
67
+ def step (self ):
68
+ return self ._step
69
+
58
70
def __repr__ (self ):
59
71
if self ._step == 1 :
60
72
return 'range(%d, %d)' % (self ._start , self ._stop )
Original file line number Diff line number Diff line change @@ -99,6 +99,16 @@ def test_slice_zero_step(self):
99
99
with self .assertRaisesRegexp (ValueError , msg ):
100
100
range (8 )[::0 ]
101
101
102
+ def test_properties (self ):
103
+ # Exception string differs between PY2/3
104
+ r = range (0 )
105
+ with self .assertRaises (AttributeError ):
106
+ r .start = 0
107
+ with self .assertRaises (AttributeError ):
108
+ r .stop = 0
109
+ with self .assertRaises (AttributeError ):
110
+ r .step = 0
111
+
102
112
103
113
if __name__ == '__main__' :
104
114
unittest .main ()
You can’t perform that action at this time.
0 commit comments