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