Skip to content

Commit

Permalink
Add fixture to disable garbage collection during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Nov 6, 2024
1 parent bde3ba1 commit 85d7f76
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plotpy/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# content of conftest.py

import gc

import guidata
import h5py
import numpy
import PIL
import pytest
import qtpy
import qwt
import scipy
Expand All @@ -17,6 +20,22 @@
execenv.verbose = "quiet"


@pytest.fixture(scope="session", autouse=True)
def disable_gc_for_tests():
"""Disable garbage collection for all tests in the session."""
# Important note:
# ---------------
# We need to disable garbage collection for all tests in the session because
# this test suite is not representative of a typical application.
# The high level of stress on the garbage collector can lead to false positives
# in tests that rely on reference counting or finalization.
# In a typical application, the garbage collector should be left enabled.

gc.disable()
yield
gc.enable()


def pytest_report_header(config):
"""Add additional information to the pytest report header."""
qtbindings_version = qtpy.PYSIDE_VERSION
Expand Down

0 comments on commit 85d7f76

Please sign in to comment.