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

Function test_check_tokenize

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

Source from the content-addressed store, hash-verified

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