Skip to content

Commit aad3e71

Browse files
committed
Fixes to pass trio-asyncio specific tests locally
1 parent c3b30a8 commit aad3e71

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

tests/interop/test_adapter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
import warnings
1111
from async_generator import asynccontextmanager
1212
from .. import utils as test_utils
13+
from trio_asyncio import TrioAsyncioDeprecationWarning
1314

1415

1516
def de_deprecate_converter(func):
1617
def wrapper(proc):
1718
with warnings.catch_warnings():
18-
warnings.simplefilter('ignore', DeprecationWarning)
19+
warnings.simplefilter('ignore', TrioAsyncioDeprecationWarning)
1920
return func(proc)
2021

2122
return wrapper

tests/test_aio_subprocess.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,12 @@ async def run_subprocess_wait_no_same_group(loop):
386386
stderr=None,
387387
start_new_session=True
388388
)
389-
_, proto = await connect
389+
transp, proto = await connect
390390
assert isinstance(proto, MySubprocessProtocol)
391391
await proto.completed
392392
assert 7 == proto.returncode
393+
with test_utils.disable_logger():
394+
transp.close()
393395

394396

395397
@pytest.mark.trio

tests/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
import logging
77
from asyncio.log import logger
88

9-
def deprecate(tc, vers=None):
9+
from trio_asyncio import TrioAsyncioDeprecationWarning
10+
11+
def deprecate(tc):
12+
return pytest.warns(TrioAsyncioDeprecationWarning)
13+
14+
def deprecate_stdlib(tc, vers=None):
1015
if vers is None or sys.version_info >= vers:
1116
return pytest.deprecated_call()
1217

trio_asyncio/_adapter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,11 @@ def trio_as_aio(proc, *, loop=None):
190190
trio_as_asyncio = trio_as_aio
191191

192192

193+
_shim_running = ContextVar("shim_running", default=False)
194+
193195
@types.coroutine
194196
def _allow_asyncio(fn, *args):
195-
shim = trio_asyncio.base._shim_running
197+
shim = _shim_running
196198
shim.set(True)
197199

198200
coro = fn(*args)
@@ -217,8 +219,6 @@ def _allow_asyncio(fn, *args):
217219
p, a = coro.send, next_send
218220

219221

220-
_shim_running = ContextVar("shim_running", default=False)
221-
222222
async def allow_asyncio(fn, *args):
223223
"""
224224
This wrapper allows you to indiscrimnately mix :mod:`trio` and

trio_asyncio/_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ._handles import Handle, TimerHandle
1313
from ._util import run_aio_future, run_aio_generator
1414
from ._deprecate import deprecated, deprecated_alias
15+
from . import _util
1516

1617
from selectors import _BaseSelectorImpl, EVENT_READ, EVENT_WRITE
1718

@@ -790,7 +791,7 @@ def __exit__(self, *tb):
790791
run_future = staticmethod(
791792
deprecated_alias(
792793
"trio_asyncio.BaseTrioEventLoop.run_future",
793-
run_aio_future,
794+
_util.run_aio_future,
794795
"0.10.0",
795796
issue=38,
796797
)

trio_asyncio/_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def new_event_loop(self):
128128
instead=None,
129129
)
130130

131-
from .sync import SyncTrioEventLoop
131+
from ._sync import SyncTrioEventLoop
132132
return SyncTrioEventLoop()
133133

134134
def get_event_loop(self):

0 commit comments

Comments
 (0)