Skip to content

Commit

Permalink
BUG: fix dummy ControlLayer shims side-effect
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shilorigins committed Aug 19, 2024
1 parent ef79415 commit 66edcb6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superscore/control_layers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions superscore/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 66edcb6

Please sign in to comment.