Pypy doesn't have sys.getrefcount(), so go back to gc
This commit is contained in:
parent
cec2183aeb
commit
a7c235732a
|
@ -159,6 +159,7 @@ class TestRaises:
|
||||||
"""
|
"""
|
||||||
Ensure pytest.raises does not leave a reference cycle (#1965).
|
Ensure pytest.raises does not leave a reference cycle (#1965).
|
||||||
"""
|
"""
|
||||||
|
import gc
|
||||||
|
|
||||||
class T:
|
class T:
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
|
@ -170,7 +171,7 @@ class TestRaises:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
t = T()
|
t = T()
|
||||||
refcount = sys.getrefcount(t)
|
refcount = len(gc.get_referrers(t))
|
||||||
|
|
||||||
if method == "function":
|
if method == "function":
|
||||||
pytest.raises(ValueError, t)
|
pytest.raises(ValueError, t)
|
||||||
|
@ -181,7 +182,7 @@ class TestRaises:
|
||||||
# ensure both forms of pytest.raises don't leave exceptions in sys.exc_info()
|
# ensure both forms of pytest.raises don't leave exceptions in sys.exc_info()
|
||||||
assert sys.exc_info() == (None, None, None)
|
assert sys.exc_info() == (None, None, None)
|
||||||
|
|
||||||
assert sys.getrefcount(t) == refcount
|
assert refcount == len(gc.get_referrers(t))
|
||||||
|
|
||||||
def test_raises_match(self):
|
def test_raises_match(self):
|
||||||
msg = r"with base \d+"
|
msg = r"with base \d+"
|
||||||
|
|
Loading…
Reference in New Issue