From 4dd76cb004dc4756cb9a318838925993cec8c20e Mon Sep 17 00:00:00 2001 From: pedohorse <13556996+pedohorse@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:25:56 +0200 Subject: [PATCH] ensure multiprocessing is not loaded if tests are skipped --- tests/tests_net_messages/test_benchmark.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/tests_net_messages/test_benchmark.py b/tests/tests_net_messages/test_benchmark.py index 8ca36ffc..a597df4c 100644 --- a/tests/tests_net_messages/test_benchmark.py +++ b/tests/tests_net_messages/test_benchmark.py @@ -1,11 +1,9 @@ -import os import asyncio import random import string import time import threading -import multiprocessing -from unittest import IsolatedAsyncioTestCase, skip +from unittest import IsolatedAsyncioTestCase, skipIf from lifeblood.logging import get_logger, set_default_loglevel from lifeblood.nethelpers import get_localhost from lifeblood.net_messages.address import AddressChain, DirectAddress @@ -17,6 +15,11 @@ from typing import Callable, List, Type, Awaitable +SKIP_BENCHMARK = True +if not SKIP_BENCHMARK: + # just importing the module may be extremely slow on CI workers + import multiprocessing + set_default_loglevel('DEBUG') logger = get_logger('message_test') @@ -123,11 +126,11 @@ def get_message_count(self) -> int: class TestBenchmarkSendReceive(IsolatedAsyncioTestCase): - @skip("no reason to benchmark on slow machines") + @skipIf(SKIP_BENCHMARK, "no reason to benchmark on slow machines") async def test_threaded(self): await self.helper_test(ThreadedFoo) - @skip("no reason to benchmark on slow machines") + @skipIf(SKIP_BENCHMARK, "no reason to benchmark on slow machines") async def test_proc(self): await self.helper_test(ProcessedFoo)