Skip to content

Commit

Permalink
aio.run.runner: Fix for cleanup decorator (#2336)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax authored Oct 11, 2024
1 parent 015b658 commit 494e994
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion aio.run.runner/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.4-dev
0.3.4
6 changes: 3 additions & 3 deletions aio.run.runner/aio/run/runner/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def cleansup(fun) -> Callable:
"""

@wraps(fun)
def wrapped(self, *args, **kwargs) -> int | None:
async def wrapped(self, *args, **kwargs) -> int | None:
try:
return fun(self, *args, **kwargs)
return await fun(self, *args, **kwargs)
finally:
self.cleanup()
await self.cleanup()

# mypy doesnt trust `@wraps` to give back a `__wrapped__` object so we
# need to code defensively here
Expand Down
4 changes: 2 additions & 2 deletions aio.run.runner/tests/test_decorators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from unittest.mock import MagicMock, PropertyMock
from unittest.mock import AsyncMock, MagicMock, PropertyMock

import pytest

Expand Down Expand Up @@ -125,7 +125,7 @@ async def test_cleansup(iters, raises):

assert run.run.__wrapped__.__cleansup__ is True

run.cleanup = MagicMock()
run.cleanup = AsyncMock()
if raises:
with pytest.raises(Exception):
await run.run(*args, **kwargs)
Expand Down

0 comments on commit 494e994

Please sign in to comment.