MCPcopy
hub / github.com/dask/dask / test_tokenize_object

Function test_tokenize_object

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

Source from the content-addressed store, hash-verified

350
351
352def test_tokenize_object():
353 with dask.config.set({"tokenize.ensure-deterministic": False}):
354 # object() tokenization is idempotent...
355 o = object()
356 assert tokenize(o) == tokenize(o)
357 # ...but not deterministic
358 assert tokenize(object()) != tokenize(object())
359
360 # Two objects don't tokenize to the same token even if their pickle output is
361 # identical. Stress id reuse by creating and dereferencing many objects in quick
362 # succession.
363 assert len({tokenize(object()) for _ in range(100)}) == 100
364
365 # You can call normalize_token even if the _ensure_deterministic context
366 # variable hasn't been set
367 assert normalize_token(o) == normalize_token(o)
368
369 with dask.config.set({"tokenize.ensure-deterministic": True}):
370 with pytest.raises(TokenizationError, match="deterministic"):
371 tokenize(o)
372 with pytest.raises(TokenizationError, match="deterministic"):
373 normalize_token(o)
374
375 # Test env override
376 assert tokenize(o, ensure_deterministic=False) == tokenize(
377 o, ensure_deterministic=False
378 )
379 with pytest.raises(TokenizationError, match="deterministic"):
380 tokenize(o, ensure_deterministic=True)
381
382
383def nested_tokenize_ensure_deterministic():

Callers

nothing calls this directly

Calls 2

tokenizeFunction · 0.90
setMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…