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

Method test_pickle

Lib/test/test_typing.py:2448–2471  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2446 self.assertEqual(weakref.ref(alias)(), alias)
2447
2448 def test_pickle(self):
2449 global T_pickle, P_pickle, TS_pickle # needed for pickling
2450 Callable = self.Callable
2451 T_pickle = TypeVar('T_pickle')
2452 P_pickle = ParamSpec('P_pickle')
2453 TS_pickle = TypeVarTuple('TS_pickle')
2454
2455 samples = [
2456 Callable[[int, str], float],
2457 Callable[P_pickle, int],
2458 Callable[P_pickle, T_pickle],
2459 Callable[Concatenate[int, P_pickle], int],
2460 Callable[Concatenate[*TS_pickle, P_pickle], int],
2461 ]
2462 for alias in samples:
2463 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
2464 with self.subTest(alias=alias, proto=proto):
2465 s = pickle.dumps(alias, proto)
2466 loaded = pickle.loads(s)
2467 self.assertEqual(alias.__origin__, loaded.__origin__)
2468 self.assertEqual(alias.__args__, loaded.__args__)
2469 self.assertEqual(alias.__parameters__, loaded.__parameters__)
2470
2471 del T_pickle, P_pickle, TS_pickle # cleaning up global state
2472
2473 def test_var_substitution(self):
2474 Callable = self.Callable

Callers

nothing calls this directly

Calls 7

TypeVarClass · 0.85
ParamSpecClass · 0.85
TypeVarTupleClass · 0.85
subTestMethod · 0.80
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected