Avoid Python 3.13+ RuntimeWarning: coroutine method 'aclose' of 'acount' was never awaited

See https://github.com/python/cpython/issues/117536#issuecomment-2036883124
This commit is contained in:
Miro Hrončok 2024-07-08 17:26:13 +02:00 committed by Casper da Costa-Luis
parent 025434544e
commit 2fbad6ad51
No known key found for this signature in database
GPG Key ID: F5126E5FBD2512AD
1 changed files with 8 additions and 4 deletions

View File

@ -48,10 +48,14 @@ async def test_generators(capsys):
_, err = capsys.readouterr()
assert '9it' in err
with tqdm(acount(), desc="async_counter") as pbar:
async for i in pbar:
if i >= 8:
break
acounter = acount()
try:
with tqdm(acounter, desc="async_counter") as pbar:
async for i in pbar:
if i >= 8:
break
finally:
await acounter.aclose()
_, err = capsys.readouterr()
assert '9it' in err