test all possible slices except big number
()
| 168 | |
| 169 | |
| 170 | def 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 | |
| 205 | test_all_slices() |
no test coverage detected