From 66edcb63af8ea465430e2a21fa6e655763da16a6 Mon Sep 17 00:00:00 2001 From: Devan Agrawal Date: Mon, 19 Aug 2024 10:50:20 -0700 Subject: [PATCH] BUG: fix dummy ControlLayer shims side-effect Since ControlLayer sets its .shims to SHIMS by default, setting attributes in dummy cl .shims changes SHIMS for the rest of the test session. Creating a new dict for the dummy_shim fixture avoids this side-effect. For redundancy, I also changed ControlLayer.__init__ to copy SHIMS instead of using the global instance. --- superscore/control_layers/core.py | 2 +- superscore/tests/conftest.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/superscore/control_layers/core.py b/superscore/control_layers/core.py index c0f3a19..b77c88a 100644 --- a/superscore/control_layers/core.py +++ b/superscore/control_layers/core.py @@ -32,7 +32,7 @@ class ControlLayer: def __init__(self, *args, shims: Optional[List[str]] = None, **kwargs): if shims is None: # load all available shims - self.shims = SHIMS + self.shims = SHIMS.copy() logger.debug('No shims specified, loading all available communication ' f'shims: {list(self.shims.keys())}') else: diff --git a/superscore/tests/conftest.py b/superscore/tests/conftest.py index bb5f842..f6c801d 100644 --- a/superscore/tests/conftest.py +++ b/superscore/tests/conftest.py @@ -742,8 +742,7 @@ def monitor(self, *args, **kwargs): @pytest.fixture(scope='function') def dummy_cl() -> ControlLayer: cl = ControlLayer() - cl.shims['ca'] = DummyShim() - cl.shims['pva'] = DummyShim() + cl.shims = {protocol: DummyShim() for protocol in ['ca', 'pva']} return cl