|
7 | 7 | import numpy as np
|
8 | 8 |
|
9 | 9 | from pandas import Series, Timestamp
|
10 |
| -from pandas.compat import range, lmap |
| 10 | +from pandas.compat import range, lmap, PY2 |
11 | 11 | import pandas.core.common as com
|
12 | 12 | import pandas.util.testing as tm
|
13 | 13 |
|
@@ -221,3 +221,20 @@ def test_standardize_mapping():
|
221 | 221 |
|
222 | 222 | dd = collections.defaultdict(list)
|
223 | 223 | assert isinstance(com.standardize_mapping(dd), partial)
|
| 224 | + |
| 225 | + |
| 226 | +@pytest.mark.parametrize( |
| 227 | + 'start,stop,step', [(0, 10, 2), (11, -2, -1), (0, -5, 1), (2, 4, 8)]) |
| 228 | +def test_get_range_parameters(start, stop, step): |
| 229 | + rng = range(start, stop, step) |
| 230 | + if PY2 and len(rng) == 0: |
| 231 | + start_expected, stop_expected, step_expected = 0, 0, 1 |
| 232 | + elif PY2 and len(rng) == 1: |
| 233 | + start_expected, stop_expected, step_expected = start, start + 1, 1 |
| 234 | + else: |
| 235 | + start_expected, stop_expected, step_expected = start, stop, step |
| 236 | + |
| 237 | + start_result, stop_result, step_result = com._get_range_parameters(rng) |
| 238 | + assert start_result == start_expected |
| 239 | + assert stop_result == stop_expected |
| 240 | + assert step_result == step_expected |
0 commit comments