Skip to content

Commit

Permalink
Move garbage collection to session fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Feb 25, 2025
1 parent e3ad3e1 commit c4cb536
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gc
import logging
import os
import warnings
Expand All @@ -18,10 +19,16 @@
from ipykernel.kernelbase import Kernel
from ipykernel.zmqshell import ZMQInteractiveShell

# ensure we don't leak History managers
# ensure we don't leak history managers
if os.name != "nt":
HistoryManager._max_inst = 1


@pytest.fixture(scope="session", autouse=True)
def _garbage_collection(request):
gc.collect()


try:
import resource
except ImportError:
Expand Down
2 changes: 0 additions & 2 deletions tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Distributed under the terms of the Modified BSD License.

import ast
import gc
import os.path
import platform
import signal
Expand Down Expand Up @@ -602,7 +601,6 @@ def test_control_thread_priority():


def test_sequential_control_messages():
gc.collect()
with new_kernel() as kc:
msg_id = kc.execute("import time")
get_reply(kc, msg_id)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_kernelapp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import gc
import json
import os
import threading
Expand Down Expand Up @@ -31,7 +30,6 @@ def test_blackhole():


def test_start_app():
gc.collect()
app = IPKernelApp()
app.kernel = MockKernel()

Expand Down

0 comments on commit c4cb536

Please sign in to comment.