Coverage for tests/test_param_cancellable.py: 100%
25 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-11 11:00 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-11 11:00 +0000
1import warnings 1ABCDEFGHIJKLM
3import anyio 1ABCDEFGHIJKLM
4import pytest 1ABCDEFGHIJKLM
5from asyncer import asyncify 1ABCDEFGHIJKLM
8def test_cancellable_warns(): 1ABCDEFGHIJKLM
9 def do_async_work(): 1abcdefghijklm
10 return "Hello World!" 1abcdefghijklm
12 async def main(): 1abcdefghijklm
13 result = await asyncify(do_async_work, cancellable=True)() 1abcdefghijklm
14 return result 1abcdefghijklm
16 with pytest.warns(DeprecationWarning) as record: 1abcdefghijklm
17 result = anyio.run(main) 1abcdefghijklm
18 assert isinstance(record[0].message, Warning) 1abcdefghijklm
19 assert ( 1abcdefghijklm
20 "The `cancellable=` keyword argument to `asyncer.asyncify()` is "
21 "deprecated since Asyncer 0.0.8" in record[0].message.args[0]
22 )
23 assert result == "Hello World!" 1abcdefghijklm
26def test_abandon_on_cancel_no(): 1ABCDEFGHIJKLM
27 def do_async_work(): 1nopqrstuvwxyz
28 return "Hello World!" 1nopqrstuvwxyz
30 async def main(): 1nopqrstuvwxyz
31 result = await asyncify(do_async_work, abandon_on_cancel=True)() 1nopqrstuvwxyz
32 return result 1nopqrstuvwxyz
34 with warnings.catch_warnings(): 1nopqrstuvwxyz
35 warnings.simplefilter("error") 1nopqrstuvwxyz
36 result = anyio.run(main) 1nopqrstuvwxyz
37 assert result == "Hello World!" 1nopqrstuvwxyz