Skip to content

Commit

Permalink
Wait for subprocesses to terminate in conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
olliesilvester committed Nov 8, 2023
1 parent d378b48 commit bde3136
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/ophyd_async/panda/panda_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _get_panda_phases(panda: PandA, ignore: Optional[List[str]] = None):

def save_panda(panda: PandA, path: str, ignore: Optional[List[str]] = None):
"""
Saves all the panda PV's to a yaml file, ignoring any PV's in the `ignore`
Saves all the panda PV's to a yaml file, ignoring any PV's in the ignore
parameter
"""
phases = yield from _get_panda_phases(panda, ignore=ignore)
Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def pva():
assert not p.poll(), p.stdout.read()

yield processes
[p.terminate() for p in processes]

for p in processes:
p.terminate()
p.communicate()


@pytest.fixture
Expand Down
1 change: 1 addition & 0 deletions tests/core/test_device_save_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pytest
import yaml
from bluesky.run_engine import RunEngine

from ophyd_async.core import (
Device,
SignalR,
Expand Down
11 changes: 4 additions & 7 deletions tests/panda/test_panda_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import TypeVar
from unittest.mock import patch

import pytest
Expand All @@ -10,8 +9,6 @@
from ophyd_async.panda import PandA, save_panda
from ophyd_async.panda.panda_utils import _get_panda_phases

T = TypeVar("T")


@pytest.fixture
async def sim_panda():
Expand All @@ -22,7 +19,7 @@ async def sim_panda():
yield sim_panda


async def test_get_panda_phases(sim_panda):
async def test_get_panda_phases(sim_panda, RE: RunEngine):
def get_phases(panda):
phases = yield from _get_panda_phases(panda)
assert len(phases) == 2
Expand All @@ -32,15 +29,15 @@ def get_phases(panda):
assert not key[-5:] == "units"
return

RE = RunEngine()
set_sim_value(sim_panda.phase_1_signal_units, 1)
RE(get_phases(sim_panda))


@patch("ophyd_async.panda.panda_utils._get_panda_phases")
@patch("ophyd_async.panda.panda_utils.save_to_yaml")
async def test_save_panda(mock_save_to_yaml, mock_get_panda_phases, sim_panda):
RE = RunEngine()
async def test_save_panda(
mock_save_to_yaml, mock_get_panda_phases, sim_panda, RE: RunEngine
):
RE(save_panda(sim_panda, "path"))
mock_get_panda_phases.assert_called_once()
mock_save_to_yaml.assert_called_once()

0 comments on commit bde3136

Please sign in to comment.