Skip to content

Commit 85d7f76

Browse files
committed
Add fixture to disable garbage collection during tests
1 parent bde3ba1 commit 85d7f76

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

plotpy/tests/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# content of conftest.py
22

3+
import gc
4+
35
import guidata
46
import h5py
57
import numpy
68
import PIL
9+
import pytest
710
import qtpy
811
import qwt
912
import scipy
@@ -17,6 +20,22 @@
1720
execenv.verbose = "quiet"
1821

1922

23+
@pytest.fixture(scope="session", autouse=True)
24+
def disable_gc_for_tests():
25+
"""Disable garbage collection for all tests in the session."""
26+
# Important note:
27+
# ---------------
28+
# We need to disable garbage collection for all tests in the session because
29+
# this test suite is not representative of a typical application.
30+
# The high level of stress on the garbage collector can lead to false positives
31+
# in tests that rely on reference counting or finalization.
32+
# In a typical application, the garbage collector should be left enabled.
33+
34+
gc.disable()
35+
yield
36+
gc.enable()
37+
38+
2039
def pytest_report_header(config):
2140
"""Add additional information to the pytest report header."""
2241
qtbindings_version = qtpy.PYSIDE_VERSION

0 commit comments

Comments
 (0)