Skip to content

Commit

Permalink
Update test_awaitable.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity authored Apr 25, 2024
1 parent cc57a80 commit 4cdfc9c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/test_awaitable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from ctypes import pythonapi
import pytest
import asyncio
import platform
from typing import Callable

tstate_init = pythonapi.PyGILState_Ensure
tstate_init.restype = ctypes.c_long
Expand Down Expand Up @@ -44,16 +46,22 @@ def test_api_types():
assert AwaitableType is pyawaitable._awaitable
assert AwaitableGenWrapperType is pyawaitable._genwrapper

def limit_leaks(memstring: str) -> None:
def decorator(func: Callable):
if platform().system != "Windows":
return pytest.mark.limit_leaks(memstring)(func)
else:
return func

@pytest.mark.limit_leaks("5 KB")
@limit_leaks("5 KB")
@pytest.mark.asyncio
async def test_new():
assert isinstance(awaitable_new(), pyawaitable._awaitable)
await asyncio.create_task(awaitable_new())
await awaitable_new()


@pytest.mark.limit_leaks("5 KB")
@limit_leaks("5 KB")
@pytest.mark.asyncio
async def test_await():
event = asyncio.Event()
Expand All @@ -67,7 +75,7 @@ async def coro():
assert event.is_set()


@pytest.mark.limit_leaks("5 KB")
@limit_leaks("5 KB")
@pytest.mark.asyncio
async def test_await_cb():
awaitable = awaitable_new()
Expand Down

0 comments on commit 4cdfc9c

Please sign in to comment.