(self)
| 3358 | self.assertEqual(opcode_in_pickle(pickle.LONG4, s), proto >= 2) |
| 3359 | |
| 3360 | def test_short_tuples(self): |
| 3361 | # Map (proto, len(tuple)) to expected opcode. |
| 3362 | expected_opcode = {(0, 0): pickle.TUPLE, |
| 3363 | (0, 1): pickle.TUPLE, |
| 3364 | (0, 2): pickle.TUPLE, |
| 3365 | (0, 3): pickle.TUPLE, |
| 3366 | (0, 4): pickle.TUPLE, |
| 3367 | |
| 3368 | (1, 0): pickle.EMPTY_TUPLE, |
| 3369 | (1, 1): pickle.TUPLE, |
| 3370 | (1, 2): pickle.TUPLE, |
| 3371 | (1, 3): pickle.TUPLE, |
| 3372 | (1, 4): pickle.TUPLE, |
| 3373 | |
| 3374 | (2, 0): pickle.EMPTY_TUPLE, |
| 3375 | (2, 1): pickle.TUPLE1, |
| 3376 | (2, 2): pickle.TUPLE2, |
| 3377 | (2, 3): pickle.TUPLE3, |
| 3378 | (2, 4): pickle.TUPLE, |
| 3379 | |
| 3380 | (3, 0): pickle.EMPTY_TUPLE, |
| 3381 | (3, 1): pickle.TUPLE1, |
| 3382 | (3, 2): pickle.TUPLE2, |
| 3383 | (3, 3): pickle.TUPLE3, |
| 3384 | (3, 4): pickle.TUPLE, |
| 3385 | } |
| 3386 | a = () |
| 3387 | b = (1,) |
| 3388 | c = (1, 2) |
| 3389 | d = (1, 2, 3) |
| 3390 | e = (1, 2, 3, 4) |
| 3391 | for proto in protocols: |
| 3392 | for x in a, b, c, d, e: |
| 3393 | s = self.dumps(x, proto) |
| 3394 | y = self.loads(s) |
| 3395 | self.assert_is_copy(x, y) |
| 3396 | expected = expected_opcode[min(proto, 3), len(x)] |
| 3397 | self.assertTrue(opcode_in_pickle(expected, s)) |
| 3398 | |
| 3399 | def test_singletons(self): |
| 3400 | # Map (proto, singleton) to expected opcode. |
nothing calls this directly
no test coverage detected