Skip to content

Commit

Permalink
tests: explicitly GC for PyPy in test_do_not_leak_response (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
woodruffw authored Jan 9, 2025
1 parent 928422d commit 19ccb8b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import gc
import platform
import weakref
from unittest import mock

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

resp = None
if platform.python_implementation() == "PyPy":
# NOTE: Need to explicitly tell PyPy to collect at this point.
# See: https://github.com/psf/cachecontrol/issues/351
# See: https://doc.pypy.org/en/latest/cpython_differences.html#differences-related-to-garbage-collection-strategies
gc.collect()

# Below this point, it should be closed because there are no more references
# to the session response.

Expand Down

0 comments on commit 19ccb8b

Please sign in to comment.