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

Function test_register_pickle_by_value

tests/cloudpickle_test.py:3107–3143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3105
3106
3107def test_register_pickle_by_value():
3108 pkg = pytest.importorskip("_cloudpickle_testpkg")
3109 mod = pytest.importorskip("_cloudpickle_testpkg.mod")
3110
3111 assert list_registry_pickle_by_value() == set()
3112
3113 register_pickle_by_value(pkg)
3114 assert list_registry_pickle_by_value() == {pkg.__name__}
3115
3116 register_pickle_by_value(mod)
3117 assert list_registry_pickle_by_value() == {pkg.__name__, mod.__name__}
3118
3119 unregister_pickle_by_value(mod)
3120 assert list_registry_pickle_by_value() == {pkg.__name__}
3121
3122 msg = f"Input should be a module object, got {pkg.__name__} instead"
3123 with pytest.raises(ValueError, match=msg):
3124 unregister_pickle_by_value(pkg.__name__)
3125
3126 unregister_pickle_by_value(pkg)
3127 assert list_registry_pickle_by_value() == set()
3128
3129 msg = f"{pkg} is not registered for pickle by value"
3130 with pytest.raises(ValueError, match=re.escape(msg)):
3131 unregister_pickle_by_value(pkg)
3132
3133 msg = f"Input should be a module object, got {pkg.__name__} instead"
3134 with pytest.raises(ValueError, match=msg):
3135 register_pickle_by_value(pkg.__name__)
3136
3137 dynamic_mod = types.ModuleType("dynamic_mod")
3138 msg = (
3139 f"{dynamic_mod} was not imported correctly, have you used an "
3140 "`import` statement to access it?"
3141 )
3142 with pytest.raises(ValueError, match=re.escape(msg)):
3143 register_pickle_by_value(dynamic_mod)
3144
3145
3146def _all_types_to_test():

Callers

nothing calls this directly

Calls 3

register_pickle_by_valueFunction · 0.90

Tested by

no test coverage detected