Skip to content

Commit 44f6559

Browse files
committed
Test fixups
1 parent 39d0f6f commit 44f6559

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

trio/testing/_check_streams.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async def send_empty_then_y():
113113
nursery.start_soon(do_send_all, b"x")
114114
assert await do_receive_some(None) == b"x"
115115

116-
with _assert_raises(_core.BusyResourceError):
116+
with _assert_raises((_core.BusyResourceError, _core._multierror.NonBaseMultiError)):
117117
async with _core.open_nursery() as nursery:
118118
nursery.start_soon(do_receive_some, 1)
119119
nursery.start_soon(do_receive_some, 1)
@@ -307,7 +307,7 @@ async def receiver():
307307

308308
async with _ForceCloseBoth(await clogged_stream_maker()) as (s, r):
309309
# simultaneous wait_send_all_might_not_block fails
310-
with _assert_raises(_core.BusyResourceError):
310+
with _assert_raises(_core._multierror.NonBaseMultiError):
311311
async with _core.open_nursery() as nursery:
312312
nursery.start_soon(s.wait_send_all_might_not_block)
313313
nursery.start_soon(s.wait_send_all_might_not_block)
@@ -316,15 +316,15 @@ async def receiver():
316316
# this test might destroy the stream b/c we end up cancelling
317317
# send_all and e.g. SSLStream can't handle that, so we have to
318318
# recreate afterwards)
319-
with _assert_raises(_core.BusyResourceError):
319+
with _assert_raises(_core._multierror.NonBaseMultiError):
320320
async with _core.open_nursery() as nursery:
321321
nursery.start_soon(s.wait_send_all_might_not_block)
322322
nursery.start_soon(s.send_all, b"123")
323323

324324
async with _ForceCloseBoth(await clogged_stream_maker()) as (s, r):
325325
# send_all and send_all blocked simultaneously should also raise
326326
# (but again this might destroy the stream)
327-
with _assert_raises(_core.BusyResourceError):
327+
with _assert_raises(_core._multierror.NonBaseMultiError):
328328
async with _core.open_nursery() as nursery:
329329
nursery.start_soon(s.send_all, b"123")
330330
nursery.start_soon(s.send_all, b"123")
@@ -496,7 +496,7 @@ async def expect_x_then_eof(r):
496496
if clogged_stream_maker is not None:
497497
async with _ForceCloseBoth(await clogged_stream_maker()) as (s1, s2):
498498
# send_all and send_eof simultaneously is not ok
499-
with _assert_raises(_core.BusyResourceError):
499+
with _assert_raises((_core.BusyResourceError, _core._multierror.NonBaseMultiError)):
500500
async with _core.open_nursery() as nursery:
501501
nursery.start_soon(s1.send_all, b"x")
502502
await _core.wait_all_tasks_blocked()
@@ -505,7 +505,7 @@ async def expect_x_then_eof(r):
505505
async with _ForceCloseBoth(await clogged_stream_maker()) as (s1, s2):
506506
# wait_send_all_might_not_block and send_eof simultaneously is not
507507
# ok either
508-
with _assert_raises(_core.BusyResourceError):
508+
with _assert_raises((_core.BusyResourceError, _core._multierror.NonBaseMultiError)):
509509
async with _core.open_nursery() as nursery:
510510
nursery.start_soon(s1.wait_send_all_might_not_block)
511511
await _core.wait_all_tasks_blocked()

trio/tests/test_signals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async def naughty():
6565

6666

6767
async def test_open_signal_receiver_conflict():
68-
with pytest.raises(trio.BusyResourceError):
68+
with pytest.raises(_core._multierror.NonBaseMultiError):
6969
with open_signal_receiver(signal.SIGILL) as receiver:
7070
async with trio.open_nursery() as nursery:
7171
nursery.start_soon(receiver.__anext__)

trio/tests/test_ssl.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -354,28 +354,28 @@ async def test_PyOpenSSLEchoStream_gives_resource_busy_errors():
354354
# PyOpenSSLEchoStream will notice and complain.
355355

356356
s = PyOpenSSLEchoStream()
357-
with pytest.raises(_core.BusyResourceError) as excinfo:
357+
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
358358
async with _core.open_nursery() as nursery:
359359
nursery.start_soon(s.send_all, b"x")
360360
nursery.start_soon(s.send_all, b"x")
361361
assert "simultaneous" in str(excinfo.value)
362362

363363
s = PyOpenSSLEchoStream()
364-
with pytest.raises(_core.BusyResourceError) as excinfo:
364+
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
365365
async with _core.open_nursery() as nursery:
366366
nursery.start_soon(s.send_all, b"x")
367367
nursery.start_soon(s.wait_send_all_might_not_block)
368368
assert "simultaneous" in str(excinfo.value)
369369

370370
s = PyOpenSSLEchoStream()
371-
with pytest.raises(_core.BusyResourceError) as excinfo:
371+
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
372372
async with _core.open_nursery() as nursery:
373373
nursery.start_soon(s.wait_send_all_might_not_block)
374374
nursery.start_soon(s.wait_send_all_might_not_block)
375375
assert "simultaneous" in str(excinfo.value)
376376

377377
s = PyOpenSSLEchoStream()
378-
with pytest.raises(_core.BusyResourceError) as excinfo:
378+
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
379379
async with _core.open_nursery() as nursery:
380380
nursery.start_soon(s.receive_some, 1)
381381
nursery.start_soon(s.receive_some, 1)
@@ -732,28 +732,28 @@ async def do_wait_send_all_might_not_block():
732732
await s.wait_send_all_might_not_block()
733733

734734
s, _ = ssl_lockstep_stream_pair(client_ctx)
735-
with pytest.raises(_core.BusyResourceError) as excinfo:
735+
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
736736
async with _core.open_nursery() as nursery:
737737
nursery.start_soon(do_send_all)
738738
nursery.start_soon(do_send_all)
739739
assert "another task" in str(excinfo.value)
740740

741741
s, _ = ssl_lockstep_stream_pair(client_ctx)
742-
with pytest.raises(_core.BusyResourceError) as excinfo:
742+
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
743743
async with _core.open_nursery() as nursery:
744744
nursery.start_soon(do_receive_some)
745745
nursery.start_soon(do_receive_some)
746746
assert "another task" in str(excinfo.value)
747747

748748
s, _ = ssl_lockstep_stream_pair(client_ctx)
749-
with pytest.raises(_core.BusyResourceError) as excinfo:
749+
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
750750
async with _core.open_nursery() as nursery:
751751
nursery.start_soon(do_send_all)
752752
nursery.start_soon(do_wait_send_all_might_not_block)
753753
assert "another task" in str(excinfo.value)
754754

755755
s, _ = ssl_lockstep_stream_pair(client_ctx)
756-
with pytest.raises(_core.BusyResourceError) as excinfo:
756+
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
757757
async with _core.open_nursery() as nursery:
758758
nursery.start_soon(do_wait_send_all_might_not_block)
759759
nursery.start_soon(do_wait_send_all_might_not_block)

trio/tests/test_testing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ async def getter(expect):
288288
nursery.start_soon(putter, b"xyz")
289289

290290
# Two gets at the same time -> BusyResourceError
291-
with pytest.raises(_core.BusyResourceError):
291+
with pytest.raises(_core._multierror.NonBaseMultiError):
292292
async with _core.open_nursery() as nursery:
293293
nursery.start_soon(getter, b"asdf")
294294
nursery.start_soon(getter, b"asdf")
@@ -359,7 +359,7 @@ async def do_send_all_count_resourcebusy():
359359
nursery.start_soon(do_send_all_count_resourcebusy)
360360
nursery.start_soon(do_send_all_count_resourcebusy)
361361

362-
assert resource_busy_count == 1
362+
assert resource_busy_count == 2
363363

364364
with assert_checkpoints():
365365
await mss.aclose()
@@ -422,7 +422,7 @@ async def do_receive_some(max_bytes):
422422
mrs.put_data(b"abc")
423423
assert await do_receive_some(None) == b"abc"
424424

425-
with pytest.raises(_core.BusyResourceError):
425+
with pytest.raises(_core._multierror.NonBaseMultiError):
426426
async with _core.open_nursery() as nursery:
427427
nursery.start_soon(do_receive_some, 10)
428428
nursery.start_soon(do_receive_some, 10)

trio/tests/test_util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def wait_with_ul1():
5353
with ul1:
5454
await wait_all_tasks_blocked()
5555

56-
with pytest.raises(_core.BusyResourceError) as excinfo:
56+
with pytest.raises(_core._multierror.NonBaseMultiError) as excinfo:
5757
async with _core.open_nursery() as nursery:
5858
nursery.start_soon(wait_with_ul1)
5959
nursery.start_soon(wait_with_ul1)

0 commit comments

Comments
 (0)