()
| 3084 | |
| 3085 | |
| 3086 | def test_register_pickle_by_value(): |
| 3087 | pkg = pytest.importorskip("_cloudpickle_testpkg") |
| 3088 | mod = pytest.importorskip("_cloudpickle_testpkg.mod") |
| 3089 | |
| 3090 | assert list_registry_pickle_by_value() == set() |
| 3091 | |
| 3092 | register_pickle_by_value(pkg) |
| 3093 | assert list_registry_pickle_by_value() == {pkg.__name__} |
| 3094 | |
| 3095 | register_pickle_by_value(mod) |
| 3096 | assert list_registry_pickle_by_value() == {pkg.__name__, mod.__name__} |
| 3097 | |
| 3098 | unregister_pickle_by_value(mod) |
| 3099 | assert list_registry_pickle_by_value() == {pkg.__name__} |
| 3100 | |
| 3101 | msg = f"Input should be a module object, got {pkg.__name__} instead" |
| 3102 | with pytest.raises(ValueError, match=msg): |
| 3103 | unregister_pickle_by_value(pkg.__name__) |
| 3104 | |
| 3105 | unregister_pickle_by_value(pkg) |
| 3106 | assert list_registry_pickle_by_value() == set() |
| 3107 | |
| 3108 | msg = f"{pkg} is not registered for pickle by value" |
| 3109 | with pytest.raises(ValueError, match=re.escape(msg)): |
| 3110 | unregister_pickle_by_value(pkg) |
| 3111 | |
| 3112 | msg = f"Input should be a module object, got {pkg.__name__} instead" |
| 3113 | with pytest.raises(ValueError, match=msg): |
| 3114 | register_pickle_by_value(pkg.__name__) |
| 3115 | |
| 3116 | dynamic_mod = types.ModuleType("dynamic_mod") |
| 3117 | msg = ( |
| 3118 | f"{dynamic_mod} was not imported correctly, have you used an " |
| 3119 | "`import` statement to access it?" |
| 3120 | ) |
| 3121 | with pytest.raises(ValueError, match=re.escape(msg)): |
| 3122 | register_pickle_by_value(dynamic_mod) |
| 3123 | |
| 3124 | |
| 3125 | def _all_types_to_test(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…