Skip to content

Commit

Permalink
leak checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jul 7, 2023
1 parent faf1ec7 commit 059c756
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
23 changes: 18 additions & 5 deletions src/gevent/testing/leakcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,25 @@ def __init__(self, testcase, function):
self.needs_setUp = False

def _ignore_object_p(self, obj):
if (
obj is self
or obj in self.__dict__.values()
or obj == self._ignore_object_p # pylint:disable=comparison-with-callable
):
if obj is self:
return False
try:
# Certain badly written __eq__ and __contains__ methods
# (I'm looking at you, Python 3.10 importlib.metadata._text!
# ``__eq__(self, other): return self.lower() == other.lower()``)
# raise AttributeError which propagates here, and must be caught.
# Similarly, we can get a TypeError
if (
obj in self.__dict__.values()
or obj == self._ignore_object_p # pylint:disable=comparison-with-callable
):
return False
except (AttributeError, TypeError):
# `obj` is things like that _text class. Also have seen
# - psycopg2._psycopg.type
# - relstorage.adapters.drivers._ClassDriverFactory
return True

kind = type(obj)
if kind in self.IGNORED_TYPES:
return False
Expand Down
14 changes: 8 additions & 6 deletions src/gevent/testing/patched_tests_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def get_switch_expected(fullname):
# The same patch that fixed that removed this test,
# because it would now fail.
'test_context.ContextTest.test_context_var_new_2',

]


Expand Down Expand Up @@ -550,8 +551,15 @@ def test(*args, **kwargs):
# 'No connection could be made because the target machine
# actively refused it'
'test_socket.NonBlockingTCPTests.testAccept',

# On appveyor, this test has been seen to fail on 3.9 and 3.8
]

if sys.version_info[2] <= (3, 9):
disabled_tests += [
'test_context.HamtTest.test_hamt_collision_3',
]

# These are a problem on 3.5; on 3.6+ they wind up getting (accidentally) disabled.
wrapped_tests.update({
'test_socket.SendfileUsingSendTest.testWithTimeout': _flaky_socket_timeout,
Expand Down Expand Up @@ -962,12 +970,6 @@ def test(*args, **kwargs):
'test_socket.GeneralModuleTests.test_getnameinfo',
]

if sys.version_info[1] == 5:
disabled_tests += [
# This test tends to time out, but only under 3.5, not under
# 3.6 or 3.7. Seen with both libev and libuv
'test_socket.SendfileUsingSendTest.testWithTimeoutTriggeredSend',
]

disabled_tests += [
'test_threading.MiscTestCase.test__all__',
Expand Down
3 changes: 1 addition & 2 deletions src/gevent/tests/test__contextvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,5 +1085,4 @@ def sub(num):


if __name__ == "__main__":
if not monkey.PY37:
unittest.main()
unittest.main()

0 comments on commit 059c756

Please sign in to comment.