Skip to content

Commit c4cb536

Browse files
committed
Move garbage collection to session fixture
1 parent e3ad3e1 commit c4cb536

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

tests/conftest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gc
12
import logging
23
import os
34
import warnings
@@ -18,10 +19,16 @@
1819
from ipykernel.kernelbase import Kernel
1920
from ipykernel.zmqshell import ZMQInteractiveShell
2021

21-
# ensure we don't leak History managers
22+
# ensure we don't leak history managers
2223
if os.name != "nt":
2324
HistoryManager._max_inst = 1
2425

26+
27+
@pytest.fixture(scope="session", autouse=True)
28+
def _garbage_collection(request):
29+
gc.collect()
30+
31+
2532
try:
2633
import resource
2734
except ImportError:

tests/test_kernel.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Distributed under the terms of the Modified BSD License.
55

66
import ast
7-
import gc
87
import os.path
98
import platform
109
import signal
@@ -602,7 +601,6 @@ def test_control_thread_priority():
602601

603602

604603
def test_sequential_control_messages():
605-
gc.collect()
606604
with new_kernel() as kc:
607605
msg_id = kc.execute("import time")
608606
get_reply(kc, msg_id)

tests/test_kernelapp.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import gc
21
import json
32
import os
43
import threading
@@ -31,7 +30,6 @@ def test_blackhole():
3130

3231

3332
def test_start_app():
34-
gc.collect()
3533
app = IPKernelApp()
3634
app.kernel = MockKernel()
3735

0 commit comments

Comments
 (0)