Skip to content

Commit 9d77d19

Browse files
committed
Add workaround for segfault after test completion
1 parent 8543b4f commit 9d77d19

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def disable_durability_check() -> Generator[None, None, None]:
2929
yield
3030

3131

32+
@pytest.fixture(autouse=True)
33+
def force_gc_between_tests() -> Generator[None, None, None]:
34+
"""Force garbage collection after each test."""
35+
# HACK: pytest segfaults at shutdown, due to causes not fully understood.
36+
# this prevents such crash.
37+
# See: https://github.com/WhyNotHugo/django-afip/pull/252
38+
yield
39+
import gc
40+
gc.collect()
41+
42+
3243
def pytest_runtest_setup(item: pytest.Function) -> None:
3344
"""Set live mode if the marker has been passed to pytest.
3445

0 commit comments

Comments
 (0)