File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
tableauserverclient/server Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ def __getitem__(self, k):
43
43
start += self .total_available
44
44
if stop < 0 :
45
45
stop += self .total_available
46
+ if start < stop and step < 0 :
47
+ # Since slicing is left inclusive and right exclusive, shift
48
+ # the start and stop values by 1 to keep that behavior
49
+ start , stop = stop - 1 , start - 1
50
+ slice_stop = stop if stop > 0 else None
51
+ k = slice (start , slice_stop , step )
46
52
47
53
k_range = range (start , stop , step )
48
54
if all (i in page_range for i in k_range ):
Original file line number Diff line number Diff line change @@ -259,6 +259,13 @@ def test_slicing_queryset(self):
259
259
self .assertEqual (3 , len (all_views [2 :5 ]))
260
260
self .assertEqual (3 , len (all_views [- 3 :]))
261
261
self .assertEqual (3 , len (all_views [- 6 :- 3 ]))
262
+ self .assertEqual (3 , len (all_views [3 :6 :- 1 ]))
263
+ self .assertEqual (3 , len (all_views [6 :3 :- 1 ]))
264
+ self .assertEqual (10 , len (all_views [::- 1 ]))
265
+ self .assertEqual (
266
+ all_views [3 :6 ],
267
+ list (reversed (all_views [3 :6 :- 1 ]))
268
+ )
262
269
263
270
self .assertEqual (all_views [- 3 ].id , "2df55de2-3a2d-4e34-b515-6d4e70b830e9" )
264
271
You can’t perform that action at this time.
0 commit comments