Skip to content

Commit

Permalink
Ignore ResourceWarning in test.
Browse files Browse the repository at this point in the history
This is expected to prevent a spurious test failure under PyPy.

Refs #1483.
  • Loading branch information
aaugustin committed Aug 11, 2024
1 parent 9ec785d commit 1853a9b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/legacy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import contextlib
import functools
import logging
import sys
import unittest


Expand Down Expand Up @@ -76,8 +77,19 @@ def assertDeprecationWarnings(self, recorded_warnings, expected_warnings):
Check recorded deprecation warnings match a list of expected messages.
"""
# Work around https://github.com/python/cpython/issues/90476.
if sys.version_info[:2] < (3, 11): # pragma: no cover
recorded_warnings = [
recorded
for recorded in recorded_warnings
if not (
type(recorded.message) is ResourceWarning
and str(recorded.message).startswith("unclosed transport")
)
]

for recorded in recorded_warnings:
self.assertEqual(type(recorded.message), DeprecationWarning)
self.assertIs(type(recorded.message), DeprecationWarning)
self.assertEqual(
{str(recorded.message) for recorded in recorded_warnings},
set(expected_warnings),
Expand Down

0 comments on commit 1853a9b

Please sign in to comment.