Explicit GC for PyPy, take 2

This commit is contained in:
Zac Hatfield-Dodds 2023-06-30 20:33:12 -07:00
parent 0311fc3384
commit 0353a94cd1
1 changed files with 6 additions and 6 deletions

View File

@ -6,10 +6,11 @@ from _pytest.pytester import Pytester
PYPY = hasattr(sys, "pypy_version_info") PYPY = hasattr(sys, "pypy_version_info")
@pytest.mark.skipif(PYPY, reason="garbage-collection differences make this flaky")
@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") @pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning")
def test_unraisable(pytester: Pytester) -> None: def test_unraisable(pytester: Pytester) -> None:
pytester.makepyfile( pytester.makepyfile(
test_it=f""" test_it="""
class BrokenDel: class BrokenDel:
def __del__(self): def __del__(self):
raise ValueError("del is broken") raise ValueError("del is broken")
@ -17,7 +18,6 @@ def test_unraisable(pytester: Pytester) -> None:
def test_it(): def test_it():
obj = BrokenDel() obj = BrokenDel()
del obj del obj
{"import gc; gc.collect()" * PYPY}
def test_2(): pass def test_2(): pass
""" """
@ -39,10 +39,11 @@ def test_unraisable(pytester: Pytester) -> None:
) )
@pytest.mark.skipif(PYPY, reason="garbage-collection differences make this flaky")
@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") @pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning")
def test_unraisable_in_setup(pytester: Pytester) -> None: def test_unraisable_in_setup(pytester: Pytester) -> None:
pytester.makepyfile( pytester.makepyfile(
test_it=f""" test_it="""
import pytest import pytest
class BrokenDel: class BrokenDel:
@ -53,7 +54,6 @@ def test_unraisable_in_setup(pytester: Pytester) -> None:
def broken_del(): def broken_del():
obj = BrokenDel() obj = BrokenDel()
del obj del obj
{"import gc; gc.collect()" * PYPY}
def test_it(broken_del): pass def test_it(broken_del): pass
def test_2(): pass def test_2(): pass
@ -76,10 +76,11 @@ def test_unraisable_in_setup(pytester: Pytester) -> None:
) )
@pytest.mark.skipif(PYPY, reason="garbage-collection differences make this flaky")
@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") @pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning")
def test_unraisable_in_teardown(pytester: Pytester) -> None: def test_unraisable_in_teardown(pytester: Pytester) -> None:
pytester.makepyfile( pytester.makepyfile(
test_it=f""" test_it="""
import pytest import pytest
class BrokenDel: class BrokenDel:
@ -91,7 +92,6 @@ def test_unraisable_in_teardown(pytester: Pytester) -> None:
yield yield
obj = BrokenDel() obj = BrokenDel()
del obj del obj
{"import gc; gc.collect()" * PYPY}
def test_it(broken_del): pass def test_it(broken_del): pass
def test_2(): pass def test_2(): pass