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

Method test_builtin_classmethod

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

Source from the content-addressed store, hash-verified

901 assert depickled_clsdict_meth is clsdict_classicmethod
902
903 def test_builtin_classmethod(self):
904 obj = 1.5 # float object
905
906 bound_clsmethod = obj.fromhex # builtin_function_or_method
907 unbound_clsmethod = type(obj).fromhex # builtin_function_or_method
908
909 depickled_bound_meth = pickle_depickle(bound_clsmethod, protocol=self.protocol)
910 depickled_unbound_meth = pickle_depickle(
911 unbound_clsmethod, protocol=self.protocol
912 )
913
914 # float.fromhex takes a string as input.
915 arg = "0x1"
916
917 # Identity on both the bound and the unbound methods cannot be
918 # tested: the bound methods are bound to different objects, and the
919 # unbound methods are actually recreated at each call.
920 assert depickled_bound_meth(arg) == bound_clsmethod(arg)
921 assert depickled_unbound_meth(arg) == unbound_clsmethod(arg)
922
923 @pytest.mark.skipif(
924 (

Callers

nothing calls this directly

Calls 1

pickle_depickleFunction · 0.85

Tested by

no test coverage detected