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

Method test_builtin_staticmethod

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

Source from the content-addressed store, hash-verified

993 reason="No known staticmethod example in the pypy stdlib",
994 )
995 def test_builtin_staticmethod(self):
996 obj = "foo" # str object
997
998 bound_staticmethod = obj.maketrans # builtin_function_or_method
999 unbound_staticmethod = type(obj).maketrans # ditto
1000 clsdict_staticmethod = type(obj).__dict__["maketrans"] # staticmethod
1001
1002 assert bound_staticmethod is unbound_staticmethod
1003
1004 depickled_bound_meth = pickle_depickle(
1005 bound_staticmethod, protocol=self.protocol
1006 )
1007 depickled_unbound_meth = pickle_depickle(
1008 unbound_staticmethod, protocol=self.protocol
1009 )
1010 depickled_clsdict_meth = pickle_depickle(
1011 clsdict_staticmethod, protocol=self.protocol
1012 )
1013
1014 assert depickled_bound_meth is bound_staticmethod
1015 assert depickled_unbound_meth is unbound_staticmethod
1016
1017 # staticmethod objects are recreated at depickling time, but the
1018 # underlying __func__ object is pickled by attribute.
1019 assert depickled_clsdict_meth.__func__ is clsdict_staticmethod.__func__
1020 type(depickled_clsdict_meth) is type(clsdict_staticmethod)
1021
1022 def test_tornado_coroutine(self):
1023 # Pickling a locally defined coroutine function

Callers

nothing calls this directly

Calls 1

pickle_depickleFunction · 0.85

Tested by

no test coverage detected