MCPcopy Create free account
hub / github.com/cloudpipe/cloudpickle / test_generic_subclass

Method test_generic_subclass

tests/cloudpickle_test.py:2624–2661  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2622 assert worker.run(check_generic, C[int], C, int) == "ok"
2623
2624 def test_generic_subclass(self):
2625 T = typing.TypeVar("T")
2626
2627 class Base(typing.Generic[T]):
2628 pass
2629
2630 class DerivedAny(Base):
2631 pass
2632
2633 class LeafAny(DerivedAny):
2634 pass
2635
2636 class DerivedInt(Base[int]):
2637 pass
2638
2639 class LeafInt(DerivedInt):
2640 pass
2641
2642 class DerivedT(Base[T]):
2643 pass
2644
2645 class LeafT(DerivedT[T]):
2646 pass
2647
2648 klasses = [Base, DerivedAny, LeafAny, DerivedInt, LeafInt, DerivedT, LeafT]
2649 for klass in klasses:
2650 assert pickle_depickle(klass, protocol=self.protocol) is klass
2651
2652 with subprocess_worker(protocol=self.protocol) as worker:
2653
2654 def check_mro(klass, expected_mro):
2655 assert klass.mro() == expected_mro
2656 return "ok"
2657
2658 for klass in klasses:
2659 mro = klass.mro()
2660 assert check_mro(klass, mro)
2661 assert worker.run(check_mro, klass, mro) == "ok"
2662
2663 def test_locally_defined_class_with_type_hints(self):
2664 with subprocess_worker(protocol=self.protocol) as worker:

Callers

nothing calls this directly

Calls 3

pickle_depickleFunction · 0.85
subprocess_workerFunction · 0.85
runMethod · 0.80

Tested by

no test coverage detected