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

Function test

dask/tests/test_expr.py:60–86  ·  view source on GitHub ↗
(c, s, a)

Source from the content-addressed store, hash-verified

58
59 @gen_cluster(client=True, Worker=Nanny, nthreads=[("", 1)])
60 async def test(c, s, a):
61
62 expr = MyExprCachedProperty(foo=1, bar=2)
63 for _ in range(10):
64 assert expr.baz == 3
65 assert expr.cached_property == 3
66
67 assert MyExprCachedProperty.called_cached_property is True
68
69 rt = pickle.loads(pickle.dumps(expr))
70 assert rt.cached_property == 3
71 assert MyExprCachedProperty.called_cached_property is True
72
73 # But this does
74 expr3 = MyExprCachedProperty(foo=1, bar=3)
75 with pytest.raises(RuntimeError):
76 expr3.cached_property
77
78 def f(expr):
79 # We want the cache to be part of the pickle, i.e. this is a
80 # different process such that the type is reset and the property can
81 # be accessed without side effects
82 assert MyExprCachedProperty.called_cached_property is False
83 assert expr.cached_property == 3
84 assert MyExprCachedProperty.called_cached_property is False
85
86 await c.submit(f, expr)
87
88 test()
89

Callers 1

Calls 2

submitMethod · 0.45

Tested by

no test coverage detected