Skip to content

Commit

Permalink
Test fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
smurfix committed Jan 18, 2023
1 parent 39d0f6f commit 4857c1b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions trio/testing/_check_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def send_empty_then_y():
nursery.start_soon(do_send_all, b"x")
assert await do_receive_some(None) == b"x"

with _assert_raises(_core.BusyResourceError):
with _assert_raises(_core._multierror.NonBaseMultiError):
async with _core.open_nursery() as nursery:
nursery.start_soon(do_receive_some, 1)
nursery.start_soon(do_receive_some, 1)
Expand Down Expand Up @@ -307,7 +307,7 @@ async def receiver():

async with _ForceCloseBoth(await clogged_stream_maker()) as (s, r):
# simultaneous wait_send_all_might_not_block fails
with _assert_raises(_core.BusyResourceError):
with _assert_raises(_core._multierror.NonBaseMultiError):
async with _core.open_nursery() as nursery:
nursery.start_soon(s.wait_send_all_might_not_block)
nursery.start_soon(s.wait_send_all_might_not_block)
Expand All @@ -316,15 +316,15 @@ async def receiver():
# this test might destroy the stream b/c we end up cancelling
# send_all and e.g. SSLStream can't handle that, so we have to
# recreate afterwards)
with _assert_raises(_core.BusyResourceError):
with _assert_raises(_core._multierror.NonBaseMultiError):
async with _core.open_nursery() as nursery:
nursery.start_soon(s.wait_send_all_might_not_block)
nursery.start_soon(s.send_all, b"123")

async with _ForceCloseBoth(await clogged_stream_maker()) as (s, r):
# send_all and send_all blocked simultaneously should also raise
# (but again this might destroy the stream)
with _assert_raises(_core.BusyResourceError):
with _assert_raises(_core._multierror.NonBaseMultiError):
async with _core.open_nursery() as nursery:
nursery.start_soon(s.send_all, b"123")
nursery.start_soon(s.send_all, b"123")
Expand Down
2 changes: 1 addition & 1 deletion trio/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def naughty():


async def test_open_signal_receiver_conflict():
with pytest.raises(trio.BusyResourceError):
with pytest.raises(_core._multierror.NonBaseMultiError):
with open_signal_receiver(signal.SIGILL) as receiver:
async with trio.open_nursery() as nursery:
nursery.start_soon(receiver.__anext__)
Expand Down
16 changes: 8 additions & 8 deletions trio/tests/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,28 +354,28 @@ async def test_PyOpenSSLEchoStream_gives_resource_busy_errors():
# PyOpenSSLEchoStream will notice and complain.

s = PyOpenSSLEchoStream()
with pytest.raises(_core.BusyResourceError) as excinfo:
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
async with _core.open_nursery() as nursery:
nursery.start_soon(s.send_all, b"x")
nursery.start_soon(s.send_all, b"x")
assert "simultaneous" in str(excinfo.value)

s = PyOpenSSLEchoStream()
with pytest.raises(_core.BusyResourceError) as excinfo:
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
async with _core.open_nursery() as nursery:
nursery.start_soon(s.send_all, b"x")
nursery.start_soon(s.wait_send_all_might_not_block)
assert "simultaneous" in str(excinfo.value)

s = PyOpenSSLEchoStream()
with pytest.raises(_core.BusyResourceError) as excinfo:
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
async with _core.open_nursery() as nursery:
nursery.start_soon(s.wait_send_all_might_not_block)
nursery.start_soon(s.wait_send_all_might_not_block)
assert "simultaneous" in str(excinfo.value)

s = PyOpenSSLEchoStream()
with pytest.raises(_core.BusyResourceError) as excinfo:
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
async with _core.open_nursery() as nursery:
nursery.start_soon(s.receive_some, 1)
nursery.start_soon(s.receive_some, 1)
Expand Down Expand Up @@ -732,28 +732,28 @@ async def do_wait_send_all_might_not_block():
await s.wait_send_all_might_not_block()

s, _ = ssl_lockstep_stream_pair(client_ctx)
with pytest.raises(_core.BusyResourceError) as excinfo:
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
async with _core.open_nursery() as nursery:
nursery.start_soon(do_send_all)
nursery.start_soon(do_send_all)
assert "another task" in str(excinfo.value)

s, _ = ssl_lockstep_stream_pair(client_ctx)
with pytest.raises(_core.BusyResourceError) as excinfo:
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
async with _core.open_nursery() as nursery:
nursery.start_soon(do_receive_some)
nursery.start_soon(do_receive_some)
assert "another task" in str(excinfo.value)

s, _ = ssl_lockstep_stream_pair(client_ctx)
with pytest.raises(_core.BusyResourceError) as excinfo:
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
async with _core.open_nursery() as nursery:
nursery.start_soon(do_send_all)
nursery.start_soon(do_wait_send_all_might_not_block)
assert "another task" in str(excinfo.value)

s, _ = ssl_lockstep_stream_pair(client_ctx)
with pytest.raises(_core.BusyResourceError) as excinfo:
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
async with _core.open_nursery() as nursery:
nursery.start_soon(do_wait_send_all_might_not_block)
nursery.start_soon(do_wait_send_all_might_not_block)
Expand Down
6 changes: 3 additions & 3 deletions trio/tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async def getter(expect):
nursery.start_soon(putter, b"xyz")

# Two gets at the same time -> BusyResourceError
with pytest.raises(_core.BusyResourceError):
with pytest.raises(_core._multierror.NonBaseMultiError):
async with _core.open_nursery() as nursery:
nursery.start_soon(getter, b"asdf")
nursery.start_soon(getter, b"asdf")
Expand Down Expand Up @@ -359,7 +359,7 @@ async def do_send_all_count_resourcebusy():
nursery.start_soon(do_send_all_count_resourcebusy)
nursery.start_soon(do_send_all_count_resourcebusy)

assert resource_busy_count == 1
assert resource_busy_count == 2

with assert_checkpoints():
await mss.aclose()
Expand Down Expand Up @@ -422,7 +422,7 @@ async def do_receive_some(max_bytes):
mrs.put_data(b"abc")
assert await do_receive_some(None) == b"abc"

with pytest.raises(_core.BusyResourceError):
with pytest.raises(_core._multierror.NonBaseMultiError):
async with _core.open_nursery() as nursery:
nursery.start_soon(do_receive_some, 10)
nursery.start_soon(do_receive_some, 10)
Expand Down
2 changes: 1 addition & 1 deletion trio/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def wait_with_ul1():
with ul1:
await wait_all_tasks_blocked()

with pytest.raises(_core.BusyResourceError) as excinfo:
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
async with _core.open_nursery() as nursery:
nursery.start_soon(wait_with_ul1)
nursery.start_soon(wait_with_ul1)
Expand Down

0 comments on commit 4857c1b

Please sign in to comment.