MCPcopy Create free account
hub / github.com/dask/dask / test_normalize_object_unserializable

Function test_normalize_object_unserializable

dask/tests/test_tokenize.py:305–329  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

303
304
305def test_normalize_object_unserializable():
306 class C:
307 def __reduce__(self):
308 assert False
309
310 c = C()
311
312 with dask.config.set({"tokenize.ensure-deterministic": False}):
313 # Not idempotent
314 assert tokenize(c) != tokenize(c)
315 # You can call normalize_token directly
316 assert normalize_token(c) != normalize_token(c)
317
318 with dask.config.set({"tokenize.ensure-deterministic": True}):
319 with pytest.raises(
320 TokenizationError, match="cannot be deterministically hashed"
321 ):
322 tokenize(c)
323
324 # Test env override
325 assert tokenize(c, ensure_deterministic=False) != tokenize(
326 c, ensure_deterministic=False
327 )
328 with pytest.raises(TokenizationError, match="cannot be deterministically hashed"):
329 tokenize(c, ensure_deterministic=True)
330
331
332def test_tokenize_partial_func_args_kwargs_consistent():

Callers

nothing calls this directly

Calls 3

tokenizeFunction · 0.90
setMethod · 0.80
CClass · 0.70

Tested by

no test coverage detected