Skip to content
Merged
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
16 changes: 14 additions & 2 deletions asyncpg/_testbase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,22 @@ def setUp(self):
self.__unhandled_exceptions = []

def tearDown(self):
if self.__unhandled_exceptions:
excs = []
for exc in self.__unhandled_exceptions:
if isinstance(exc, ConnectionResetError):
texc = traceback.TracebackException.from_exception(
exc, lookup_lines=False)
if texc.stack[-1].name == "_call_connection_lost":
# On Windows calling socket.shutdown may raise
# ConnectionResetError, which happens in the
# finally block of _call_connection_lost.
continue
excs.append(exc)

if excs:
formatted = []

for i, context in enumerate(self.__unhandled_exceptions):
for i, context in enumerate(excs):
formatted.append(self._format_loop_exception(context, i + 1))

self.fail(
Expand Down
Loading