MCPcopy
hub / github.com/pallets/werkzeug / test_basic_local_asyncio

Function test_basic_local_asyncio

tests/test_local.py:57–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55
56
57def test_basic_local_asyncio():
58 ns = local.Local(_cv_ns)
59 ns.foo = 0
60 values = []
61
62 async def value_setter(idx):
63 await asyncio.sleep(0.01 * idx)
64 ns.foo = idx
65 await asyncio.sleep(0.02)
66 values.append(ns.foo)
67
68 async def main():
69 futures = [asyncio.ensure_future(value_setter(i)) for i in [1, 2, 3]]
70 await asyncio.gather(*futures)
71
72 asyncio.run(main())
73 assert sorted(values) == [1, 2, 3]
74
75 def delfoo():
76 del ns.foo
77
78 delfoo()
79 pytest.raises(AttributeError, lambda: ns.foo)
80 pytest.raises(AttributeError, delfoo)
81
82 local.release_local(ns)
83
84
85def test_local_release():

Callers

nothing calls this directly

Calls 3

mainFunction · 0.85
delfooFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected