Skip to content

Commit

Permalink
narrowed down all tests which aren't to do with standard detector uns…
Browse files Browse the repository at this point in the history
…tage
  • Loading branch information
evalott100 committed Aug 27, 2024
1 parent 864bb5c commit d4628cd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ async def collect_stream_docs(
def close(self) -> None:
if self._handle_for_h5_file:
self._handle_for_h5_file.close()
print("file closed")
self._handle_for_h5_file = None

async def observe_indices_written(
Expand Down
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import os
import pprint
import subprocess
import sys
import time
Expand Down Expand Up @@ -87,8 +88,8 @@ def error_and_kill_pending_tasks():
# for other reasons then we don't have to error here
if unfinished_tasks and request.session.testsfailed == fail_count:
raise RuntimeError(
f"Not all tasks {unfinished_tasks} "
f"closed during test {request.node.name}."
f"Not all tasks closed during test {request.node.name}:\n"
f"{pprint.pformat(unfinished_tasks)}"
)

request.addfinalizer(error_and_kill_pending_tasks)
Expand Down Expand Up @@ -126,10 +127,9 @@ def clean_event_loop():
# If the tasks are still pending because the test failed
# for other reasons then we don't have to error here
if unfinished_tasks and request.session.testsfailed == fail_count:
import pprint
raise RuntimeError(
f"Not all tasks \n{pprint.pformat(unfinished_tasks)}\n"
f"closed during test {request.node.name}."
f"Not all tasks closed during test {request.node.name}:\n"
f"{pprint.pformat(unfinished_tasks)}"
)

request.addfinalizer(clean_event_loop)
Expand Down
16 changes: 7 additions & 9 deletions tests/epics/adsimdetector/test_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,12 @@ def plan():
assert 0 == (yield from bps.rd(hdfb.num_capture))
assert adcore.FileWriteMode.stream == (yield from bps.rd(hdfb.file_write_mode))

assert (
(yield from bps.rd(writer_a.hdf.file_path)) ==
str(info_a.directory_path)
)
file_name_a = (yield from bps.rd(writer_a.hdf.file_name))
assert (yield from bps.rd(writer_a.hdf.file_path)) == str(info_a.directory_path)
file_name_a = yield from bps.rd(writer_a.hdf.file_name)
assert file_name_a == info_a.filename

assert (yield from bps.rd(writer_b.hdf.file_path)) == str(info_b.directory_path)
file_name_b = (yield from bps.rd(writer_b.hdf.file_name))
file_name_b = yield from bps.rd(writer_b.hdf.file_name)
assert file_name_b == info_b.filename

RE(plan())
Expand Down Expand Up @@ -351,7 +348,7 @@ async def test_trigger_logic():
),
],
)
async def test_detector_with_unnamed_or_disconnected_config_sigs(
def test_detector_with_unnamed_or_disconnected_config_sigs(
RE,
static_filename_provider: StaticFilenameProvider,
tmp_path: Path,
Expand All @@ -363,7 +360,7 @@ async def test_detector_with_unnamed_or_disconnected_config_sigs(

some_other_driver = adcore.ADBaseIO("TEST", name=driver_name)

hdf = adcore.NDFileHDFIO("FOO:HDF:")
hdf = adcore.NDFileHDFIO("FOO:HDF:", name="hdf")
det = adsimdetector.SimDetector(
drv,
hdf,
Expand All @@ -376,8 +373,9 @@ def plan():
yield from ops.ensure_connected(det, mock=True)
yield from count_sim([det], times=1)

loop = asyncio.get_event_loop()
with pytest.raises(Exception) as exc:
RE(plan())
RE(plan(), loop=loop)

assert isinstance(exc.value.args[0], AsyncStatus)
assert str(exc.value.args[0].exception()) == error_output
3 changes: 0 additions & 3 deletions tests/sim/test_sim_detector.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import asyncio
from collections import defaultdict
from pprint import pprint

import bluesky.plans as bp
import h5py
import numpy as np
from bluesky import RunEngine
from bluesky import plan_stubs as bps

from ophyd_async.core import assert_emitted
from ophyd_async.plan_stubs import ensure_connected
Expand Down

0 comments on commit d4628cd

Please sign in to comment.