Skip to content

Commit cd1174f

Browse files
committed
-
1 parent 69123c0 commit cd1174f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

source_py3/test_python_toolbox/test_sequence_tools/test_parse_slice.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from python_toolbox import math_tools
55

6-
from python_toolbox.sequence_tools import parse_slice
6+
from python_toolbox.sequence_tools import CanonicalSlice
77

88

99
infinity = float('inf')
@@ -23,17 +23,20 @@ def test():
2323
slice(None, None, -2)]
2424

2525
for slice_ in slices:
26-
(start, stop, step) = parse_slice(slice_)
26+
canonical_slice = CanonicalSlice(slice_)
2727

2828
# Replacing `infinity` with huge number cause Python's lists can't
2929
# handle `infinity`:
30-
if abs(start) == infinity: start = 10**10 * math_tools.get_sign(start)
31-
if abs(stop) == infinity: stop = 10**10 * math_tools.get_sign(stop)
32-
if abs(step) == infinity: step = 10**10 * math_tools.get_sign(step)
30+
if abs(canonical_slice.start) == infinity:
31+
start = 10**10 * math_tools.get_sign(canonical_slice.start)
32+
if abs(canonical_slice.stop) == infinity:
33+
stop = 10**10 * math_tools.get_sign(canonical_slice.stop)
34+
if abs(canonical_slice.step) == infinity:
35+
step = 10**10 * math_tools.get_sign(canonical_slice.step)
3336
#######################################################################
3437

35-
assert [start, stop, step].count(None) == 0
38+
assert [canonical_slice.start, canonical_slice.stop,
39+
canonical_slice.step].count(None) == 0
3640

37-
parsed_slice = slice(start, stop, step)
3841
for range_ in ranges:
39-
assert range_[slice_] == range_[parsed_slice]
42+
assert range_[slice_] == range_[canonical_slice.slice_]

0 commit comments

Comments
 (0)