Skip to content

Commit

Permalink
Ensure dynamic classes are garbage collected between tests (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson authored Jul 4, 2024
1 parent 11c148a commit 992c5df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# SPDX-FileCopyrightText: Copyright (c) 2023-2024, Kr8s Developers (See LICENSE for list)
# SPDX-License-Identifier: BSD 3-Clause License
import gc
import os
import time

import pytest
from pytest_kind.cluster import KindCluster


@pytest.fixture
def ensure_gc():
"""Ensure garbage collection is run before and after the test."""
gc.collect()
yield
gc.collect()


@pytest.fixture(scope="session", autouse=True)
def k8s_cluster(request) -> KindCluster:
image = None
Expand Down
2 changes: 1 addition & 1 deletion kr8s/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ async def test_nonexisting_resource_type():
"certificatesigningrequests.certificates.k8s.io/v1",
],
)
async def test_dynamic_classes(kind):
async def test_dynamic_classes(kind, ensure_gc):
from kr8s.asyncio.objects import get_class

api = await kr8s.asyncio.api()
Expand Down

0 comments on commit 992c5df

Please sign in to comment.