Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 58 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,45 @@ def skip(rel_id):
# hangs on 3.11+, fails without hanging on 3.8-3.10
skip("test_windows_events.py::ProactorLoopCtrlC::test_ctrl_c")

if sys.platform == "darwin":
# These time out on GitHub Actions, unclear why -- possibly an
# interaction with macOS safety features for stopping processes
# from accessing the network without permissions. They pass fine
# on a local machine.
for kind in ("Kqueue", "Poll", "Select"):
for what in (
"create_connection",
"create_connection_local_addr",
"create_connection_local_addr_in_use",
"create_ssl_connection",
# This one seems to nondeterministically raise ResourceWarnings
"create_server_ssl_verify_failed",
):
skip(f"test_events.py::{kind}EventLoopTests::test_{what}")
for what in (
"create_connection_sock",
"huge_content",
"huge_content_recvinto",
"sock_client_connect_racing",
"sock_client_ops",
"sock_client_racing",
):
skip(f"test_sock_lowlevel.py::{kind}EventLoopTests::test_{what}")
for what in (
"async_writer_api",
"async_writer_api_exception_after_close",
"eof_feed_when_closing_writer",
"loop_is_closed_resource_warnings",
"open_connection",
"open_connection_error",
"open_connection_happy_eyeball_refcycles",
"open_connection_no_loop_ssl",
"unclosed_resource_warnings",
"wait_closed_on_close",
"wait_closed_on_close_with_unread_data",
):
skip(f"test_streams.py::StreamTests::test_{what}")

if sys.implementation.name == "pypy":
# This test depends on the C implementation of asyncio.Future, and
# unlike most such tests it is not configured to be skipped if
Expand Down Expand Up @@ -199,12 +238,28 @@ def skip(rel_id):
xfail(
"test_futures2.py::PyFutureTests::test_task_exc_handler_correct_context"
)
xfail(
"test_futures2.py::CFutureTests::test_task_exc_handler_correct_context"
)
if sys.version_info < (3, 13):
xfail(
"test_futures2.py::CFutureTests::test_task_exc_handler_correct_context"
)

# This test assumes that get_event_loop_policy().get_event_loop() doesn't
# automatically return the running loop
skip(
"test_subprocess.py::GenericWatcherTests::test_create_subprocess_with_pidfd"
)

if sys.version_info >= (3, 13):
if sys.platform == "win32":
for which in ("read", "write", "read_write"):
# These use a facility of the ProactorEventLoop that
# trio-asyncio doesn't support
xfail(
"test_subprocess.py::SubprocessProactorTests::"
f"test_subprocess_{which}_pipe_cancelled"
)
# Fails nondeterministically - unclear issue
skip(
"test_tasks.py::RunCoroutineThreadsafeTests::"
"test_run_coroutine_threadsafe_and_cancel"
)
2 changes: 1 addition & 1 deletion tests/interop/test_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ async def cancel_trio(seen):
seen.flag |= 8

seen = Seen()
with trio.testing.RaisesGroup(asyncio.CancelledError):
with pytest.RaisesGroup(asyncio.CancelledError):
await cancel_trio(seen)
assert seen.flag == 1 | 8

Expand Down
8 changes: 4 additions & 4 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ async def run_asyncio_loop(nursery, *, task_status=trio.TASK_STATUS_IGNORED):
import signal
import threading

with trio.testing.RaisesGroup(KeyboardInterrupt):
with pytest.RaisesGroup(KeyboardInterrupt):
async with trio.open_nursery() as nursery:
await nursery.start(run_asyncio_loop, nursery)
# Trigger KeyboardInterrupt that should propagate accross the coroutines
Expand Down Expand Up @@ -270,7 +270,7 @@ async def trio_task():
scope.cancel()
assert fut.done()
if throw_another:
with trio.testing.RaisesGroup(trio.testing.Matcher(ValueError, match="hi")):
with pytest.RaisesGroup(pytest.RaisesExc(ValueError, match="hi")):
fut.result()
else:
assert fut.cancelled()
Expand Down Expand Up @@ -333,9 +333,9 @@ def collect_exceptions(loop, context):
)
expected = [ValueError("hi"), ValueError("lo"), KeyError(), IndexError()]
await raise_in_aio_loop(expected[0])
with trio.testing.RaisesGroup(SystemExit, flatten_subgroups=True):
with pytest.RaisesGroup(SystemExit, flatten_subgroups=True):
await raise_in_aio_loop(SystemExit(0))
with trio.testing.RaisesGroup(SystemExit, flatten_subgroups=True) as result:
with pytest.RaisesGroup(SystemExit, flatten_subgroups=True) as result:
await raise_in_aio_loop(BaseExceptionGroup("", [expected[1], SystemExit()]))

assert len(result.value.exceptions) == 1
Expand Down
4 changes: 2 additions & 2 deletions tests/test_trio_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ async def test_cancel_loop_with_tasks(autojump_clock, shield, body_raises):
record = []

if body_raises:
catcher = trio.testing.RaisesGroup(
trio.testing.Matcher(ValueError, match="hi"), flatten_subgroups=True
catcher = pytest.RaisesGroup(
pytest.RaisesExc(ValueError, match="hi"), flatten_subgroups=True
)
else:
catcher = contextlib.nullcontext()
Expand Down
Loading