MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_all_slices

Function test_all_slices

extra_tests/snippets/builtin_slice.py:170–202  ·  view source on GitHub ↗

test all possible slices except big number

()

Source from the content-addressed store, hash-verified

168
169
170def test_all_slices():
171 """
172 test all possible slices except big number
173 """
174
175 mod = __import__("cpython_generated_slices")
176
177 ll = mod.LL
178 start = mod.START
179 end = mod.END
180 step = mod.STEP
181 slices_res = mod.SLICES_RES
182
183 count = 0
184 failures = []
185 for s in start:
186 for e in end:
187 for t in step:
188 lhs = ll[s:e:t]
189 try:
190 assert lhs == slices_res[count]
191 except AssertionError:
192 failures.append(
193 "start: {} ,stop: {}, step {}. Expected: {}, found: {}".format(
194 s, e, t, lhs, slices_res[count]
195 )
196 )
197 count += 1
198
199 if failures:
200 for f in failures:
201 print(f)
202 print(len(failures), "slices failed")
203
204
205test_all_slices()

Callers 1

builtin_slice.pyFile · 0.85

Calls 5

lenFunction · 0.85
__import__Function · 0.50
printFunction · 0.50
appendMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected