MCPcopy
hub / github.com/dask/dask / test_dispatch_lazy

Function test_dispatch_lazy

dask/tests/test_utils.py:193–213  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191
192
193def test_dispatch_lazy():
194 # this tests the recursive component of dispatch
195 foo = Dispatch()
196 foo.register(int, lambda a: a)
197
198 import decimal
199
200 # keep it outside lazy dec for test
201 def foo_dec(a):
202 return a + 1
203
204 @foo.register_lazy("decimal")
205 def register_decimal():
206 import decimal
207
208 foo.register(decimal.Decimal, foo_dec)
209
210 # This test needs to be *before* any other calls
211 assert foo.dispatch(decimal.Decimal) == foo_dec
212 assert foo(decimal.Decimal(1)) == decimal.Decimal(2)
213 assert foo(1) == 1
214
215
216def test_dispatch_lazy_walks_mro():

Callers

nothing calls this directly

Calls 4

registerMethod · 0.95
dispatchMethod · 0.95
DispatchClass · 0.90
fooFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…