Skip to content

Commit e317d9c

Browse files
authored
Merge pull request #2900 from jakkdl/test_open_tcp_listeners_codecov
open_tcp_listeners exception __cause__ is always an ExceptionGroup
2 parents 7642383 + 44d02ac commit e317d9c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/trio/_tests/test_highlevel_open_tcp_listeners.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,12 @@ async def test_open_tcp_listeners_some_address_families_unavailable(
332332
with pytest.raises(OSError, match="This system doesn't support") as exc_info:
333333
await open_tcp_listeners(80, host="example.org")
334334

335-
if isinstance(exc_info.value.__cause__, BaseExceptionGroup):
336-
for subexc in exc_info.value.__cause__.exceptions:
337-
assert "nope" in str(subexc)
338-
else:
339-
assert isinstance(exc_info.value.__cause__, OSError)
340-
assert "nope" in str(exc_info.value.__cause__)
335+
# open_listeners always creates an exceptiongroup with the
336+
# unsupported address families, regardless of the value of
337+
# strict_exception_groups or number of unsupported families.
338+
assert isinstance(exc_info.value.__cause__, BaseExceptionGroup)
339+
for subexc in exc_info.value.__cause__.exceptions:
340+
assert "nope" in str(subexc)
341341
else:
342342
listeners = await open_tcp_listeners(80)
343343
for listener in listeners:

0 commit comments

Comments
 (0)