Skip to content

Commit 19ccb8b

Browse files
authored
tests: explicitly GC for PyPy in test_do_not_leak_response (#352)
1 parent 928422d commit 19ccb8b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: tests/test_adapter.py

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
import gc
6+
import platform
67
import weakref
78
from unittest import mock
89

@@ -82,6 +83,12 @@ def test_do_not_leak_response(self, url, sess):
8283
# We should not break this.
8384

8485
resp = None
86+
if platform.python_implementation() == "PyPy":
87+
# NOTE: Need to explicitly tell PyPy to collect at this point.
88+
# See: https://github.com/psf/cachecontrol/issues/351
89+
# See: https://doc.pypy.org/en/latest/cpython_differences.html#differences-related-to-garbage-collection-strategies
90+
gc.collect()
91+
8592
# Below this point, it should be closed because there are no more references
8693
# to the session response.
8794

0 commit comments

Comments
 (0)