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

Function test_check_tokenize

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

Source from the content-addressed store, hash-verified

80
81
82def test_check_tokenize():
83 # idempotent and deterministic
84 check_tokenize(123)
85 # returns tokenized value
86 assert tokenize(123) == check_tokenize(123)
87
88 # idempotent, but not deterministic
89 class A:
90 def __init__(self):
91 self.tok = random.random()
92
93 def __reduce__(self):
94 return A, ()
95
96 def __dask_tokenize__(self):
97 return self.tok
98
99 a = A()
100 with pytest.raises(AssertionError):
101 check_tokenize(a)
102
103 # Not idempotent
104 class B:
105 def __dask_tokenize__(self):
106 return random.random()
107
108 b = B()
109 with pytest.raises(AssertionError):
110 check_tokenize(b)
111
112
113def test_tokenize():

Callers

nothing calls this directly

Calls 4

tokenizeFunction · 0.90
check_tokenizeFunction · 0.85
BClass · 0.85
AClass · 0.70

Tested by

no test coverage detected