Skip to content

Commit

Permalink
Pypy doesn't have sys.getrefcount(), so go back to gc
Browse files Browse the repository at this point in the history
  • Loading branch information
bluetech committed Aug 20, 2019
1 parent cec2183 commit a7c2357
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions testing/python/raises.py
Expand Up @@ -159,6 +159,7 @@ def test_raises_cyclic_reference(self, method):
"""
Ensure pytest.raises does not leave a reference cycle (#1965).
"""
import gc

class T:
def __call__(self):
Expand All @@ -170,7 +171,7 @@ def __call__(self):
raise ValueError

t = T()
refcount = sys.getrefcount(t)
refcount = len(gc.get_referrers(t))

if method == "function":
pytest.raises(ValueError, t)
Expand All @@ -181,7 +182,7 @@ def __call__(self):
# ensure both forms of pytest.raises don't leave exceptions in sys.exc_info()
assert sys.exc_info() == (None, None, None)

assert sys.getrefcount(t) == refcount
assert refcount == len(gc.get_referrers(t))

def test_raises_match(self):
msg = r"with base \d+"
Expand Down

0 comments on commit a7c2357

Please sign in to comment.