From d0e4e73b810ad22d9fc9ef1130ae088053782fec Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Mon, 2 Dec 2024 09:38:29 +0100 Subject: [PATCH] Remove duplicate codes --- tests/persistence/test_inmemory.py | 4 +--- tests/persistence/test_pickle.py | 4 ++-- tests/rmq/test_process_comms.py | 1 - tests/test_communications.py | 2 -- tests/test_expose.py | 38 +----------------------------- tests/test_process_comms.py | 2 +- tests/test_processes.py | 7 ++---- 7 files changed, 7 insertions(+), 51 deletions(-) diff --git a/tests/persistence/test_inmemory.py b/tests/persistence/test_inmemory.py index b0db46e7..9e3141de 100644 --- a/tests/persistence/test_inmemory.py +++ b/tests/persistence/test_inmemory.py @@ -1,11 +1,9 @@ # -*- coding: utf-8 -*- import unittest -from ..utils import ProcessWithCheckpoint - import plumpy -import plumpy +from ..utils import ProcessWithCheckpoint class TestInMemoryPersister(unittest.TestCase): diff --git a/tests/persistence/test_pickle.py b/tests/persistence/test_pickle.py index dd68b4fd..da4ede51 100644 --- a/tests/persistence/test_pickle.py +++ b/tests/persistence/test_pickle.py @@ -5,10 +5,10 @@ if getattr(tempfile, 'TemporaryDirectory', None) is None: from backports import tempfile -from ..utils import ProcessWithCheckpoint - import plumpy +from ..utils import ProcessWithCheckpoint + class TestPicklePersister(unittest.TestCase): def test_save_load_roundtrip(self): diff --git a/tests/rmq/test_process_comms.py b/tests/rmq/test_process_comms.py index 4c7a4f1a..c6826a24 100644 --- a/tests/rmq/test_process_comms.py +++ b/tests/rmq/test_process_comms.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import asyncio -import copy import kiwipy import pytest diff --git a/tests/test_communications.py b/tests/test_communications.py index 37177d6e..f7e04255 100644 --- a/tests/test_communications.py +++ b/tests/test_communications.py @@ -4,8 +4,6 @@ import pytest from kiwipy import CommunicatorHelper -import pytest -from kiwipy import CommunicatorHelper from plumpy.communications import LoopCommunicator diff --git a/tests/test_expose.py b/tests/test_expose.py index f48ce32e..c5e6014c 100644 --- a/tests/test_expose.py +++ b/tests/test_expose.py @@ -1,47 +1,11 @@ # -*- coding: utf-8 -*- import unittest -from .utils import NewLoopProcess - from plumpy.ports import PortNamespace from plumpy.process_spec import ProcessSpec from plumpy.processes import Process - -def validator_function(input, port): - pass - - -class BaseNamespaceProcess(NewLoopProcess): - @classmethod - def define(cls, spec): - super().define(spec) - spec.input('top') - spec.input('namespace.sub_one') - spec.input('namespace.sub_two') - spec.inputs['namespace'].valid_type = (int, float) - spec.inputs['namespace'].validator = validator_function - - -class BaseProcess(NewLoopProcess): - @classmethod - def define(cls, spec): - super().define(spec) - spec.input('a', valid_type=str, default='a') - spec.input('b', valid_type=str, default='b') - spec.inputs.dynamic = True - spec.inputs.valid_type = str - - -class ExposeProcess(NewLoopProcess): - @classmethod - def define(cls, spec): - super().define(spec) - spec.expose_inputs(BaseProcess, namespace='base.name.space') - spec.input('c', valid_type=int, default=1) - spec.input('d', valid_type=int, default=2) - spec.inputs.dynamic = True - spec.inputs.valid_type = int +from .utils import NewLoopProcess def validator_function(input, port): diff --git a/tests/test_process_comms.py b/tests/test_process_comms.py index c59737ac..44947230 100644 --- a/tests/test_process_comms.py +++ b/tests/test_process_comms.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- import pytest -from tests import utils import plumpy from plumpy import process_comms +from tests import utils class Process(plumpy.Process): diff --git a/tests/test_processes.py b/tests/test_processes.py index cec20c51..eb5bf599 100644 --- a/tests/test_processes.py +++ b/tests/test_processes.py @@ -3,19 +3,16 @@ import asyncio import enum -from plumpy.process_comms import KillMessage import unittest import kiwipy import pytest -from tests import utils - -import plumpy -import pytest import plumpy from plumpy import BundleKeys, Process, ProcessState +from plumpy.process_comms import KillMessage from plumpy.utils import AttributesFrozendict +from tests import utils class ForgetToCallParent(plumpy.Process):