diff --git a/src/pandablocks_ioc/__main__.py b/src/pandablocks_ioc/__main__.py index 33c5d184..b8b85045 100644 --- a/src/pandablocks_ioc/__main__.py +++ b/src/pandablocks_ioc/__main__.py @@ -1,7 +1,3 @@ -from argparse import ArgumentParser - -from . import __version__ - import logging import click @@ -32,10 +28,6 @@ def cli(ctx, log_level: str): if ctx.invoked_subcommand is None: click.echo(cli.get_help(ctx)) - parser = ArgumentParser() - parser.add_argument("-v", "--version", action="version", version=__version__) - args = parser.parse_args(args) - @cli.command() @click.argument("host") diff --git a/src/pandablocks_ioc/_pvi.py b/src/pandablocks_ioc/_pvi.py index 7ddf8bab..c2476ce0 100644 --- a/src/pandablocks_ioc/_pvi.py +++ b/src/pandablocks_ioc/_pvi.py @@ -83,7 +83,7 @@ def add_data_capture_pvi_info( component = SignalRW( name=epics_to_pvi_name(data_capture_record_name), pv=data_capture_record_name, - widget=ButtonPanel(actions=dict(Start="1", Stop="0")), + widget=ButtonPanel(actions={"Start": "1", "Stop": "0"}), read_widget=LED(), ) add_pvi_info_to_record(data_capture_pvi_record, data_capture_record_name, "rw") @@ -97,7 +97,7 @@ def add_pcap_arm_pvi_info(group: PviGroup, pcap_arm_pvi_record: RecordWrapper): component = SignalRW( name=epics_to_pvi_name(pcap_arm_record_name), pv=pcap_arm_record_name, - widget=ButtonPanel(actions=dict(Arm="1", Disarm="0")), + widget=ButtonPanel(actions={"Arm": "1", "Disarm": "0"}), read_widget=LED(), ) add_pvi_info_to_record(pcap_arm_pvi_record, pcap_arm_record_name, "rw") @@ -123,7 +123,7 @@ def add_automatic_pvi_info( component = SignalRW( name=pvi_name, pv=record_name, - widget=ButtonPanel(actions=dict(Arm="1", Disarm="0")), + widget=ButtonPanel(actions={"Arm": "1", "Disarm": "0"}), read_widget=LED(), ) access = "rw" diff --git a/src/pandablocks_ioc/ioc.py b/src/pandablocks_ioc/ioc.py index 5bf47efb..6c1fa3f0 100644 --- a/src/pandablocks_ioc/ioc.py +++ b/src/pandablocks_ioc/ioc.py @@ -573,7 +573,7 @@ def _create_record_info( record_creation_func: Callable, data_type_func: Callable, group: PviGroup, - labels: List[str] = [], + labels: Optional[List[str]] = None, *args, **kwargs, ) -> RecordInfo: @@ -605,6 +605,10 @@ def _create_record_info( RecordInfo: Class containing the created record and anything needed for updating the record. """ + + if labels is None: + labels = [] + extra_kwargs: Dict[str, Any] = {} assert ( record_creation_func in self._builder_methods diff --git a/tests/fixtures/mocked_panda.py b/tests/fixtures/mocked_panda.py index 990d08bd..9ef29cf4 100644 --- a/tests/fixtures/mocked_panda.py +++ b/tests/fixtures/mocked_panda.py @@ -10,12 +10,12 @@ from multiprocessing.connection import Connection from pathlib import Path from typing import Any, Generator, Iterator, Optional, Tuple, TypeVar +from unittest.mock import MagicMock, patch from uuid import uuid4 import pytest import pytest_asyncio from aioca import purge_channel_caches -from mock import MagicMock, patch from pandablocks.commands import ( Arm, ChangeGroup, diff --git a/tests/test-bobfiles/regenerate_test_bobfiles.py b/tests/test-bobfiles/regenerate_test_bobfiles.py index 79c727db..e1f43b90 100755 --- a/tests/test-bobfiles/regenerate_test_bobfiles.py +++ b/tests/test-bobfiles/regenerate_test_bobfiles.py @@ -8,6 +8,7 @@ from time import sleep import pytest + from fixtures.mocked_panda import ( BOBFILE_DIR, TEST_PREFIX, diff --git a/tests/test_hdf_ioc.py b/tests/test_hdf_ioc.py index 1d6d8e6a..5b514c53 100644 --- a/tests/test_hdf_ioc.py +++ b/tests/test_hdf_ioc.py @@ -13,16 +13,6 @@ import pytest import pytest_asyncio from aioca import DBR_CHAR_STR, CANothing, caget, caput -from fixtures.mocked_panda import ( - TIMEOUT, - MockedAsyncioClient, - Rows, - append_random_uppercase, - custom_logger, - enable_codecov_multiprocess, - get_multiprocessing_context, - select_and_recv, -) from mock.mock import AsyncMock, MagicMock, patch from pandablocks.asyncio import AsyncioClient from pandablocks.responses import ( @@ -35,6 +25,16 @@ ) from softioc import asyncio_dispatcher, builder, softioc +from fixtures.mocked_panda import ( + TIMEOUT, + MockedAsyncioClient, + Rows, + append_random_uppercase, + custom_logger, + enable_codecov_multiprocess, + get_multiprocessing_context, + select_and_recv, +) from pandablocks_ioc._hdf_ioc import ( CaptureMode, HDF5Buffer, @@ -676,11 +676,14 @@ def test_hdf_buffer_forever(differently_sized_framedata, tmp_path): assert buffer.finish_capturing assert len(frames_written_to_file) == 14 - sum( - len(frame.data) - for frame in frames_written_to_file - if isinstance(frame, FrameData) - ) == 116 + assert ( + sum( + len(frame.data) + for frame in frames_written_to_file + if isinstance(frame, FrameData) + ) + == 116 + ) def test_hdf_buffer_last_n(differently_sized_framedata, tmp_path): @@ -780,12 +783,12 @@ def test_hdf_buffer_last_n_large_data(tmp_path): large_data = [ ReadyData(), StartData([], 0, "Scaled", "Framed", 52), - FrameData(numpy.zeros((25000))), - FrameData(numpy.zeros((25000))), - FrameData(numpy.zeros((25000))), - FrameData(numpy.zeros((25000))), - FrameData(numpy.zeros((25000))), - FrameData(numpy.append(numpy.zeros((15000)), numpy.arange(1, 10001))), + FrameData(numpy.zeros(25000)), + FrameData(numpy.zeros(25000)), + FrameData(numpy.zeros(25000)), + FrameData(numpy.zeros(25000)), + FrameData(numpy.zeros(25000)), + FrameData(numpy.append(numpy.zeros(15000), numpy.arange(1, 10001))), EndData(150000, EndReason.OK), ] @@ -797,7 +800,7 @@ def test_hdf_buffer_last_n_large_data(tmp_path): expected_output = [ StartData([], 0, "Scaled", "Framed", 52), - FrameData(numpy.append(numpy.zeros((15000)), numpy.arange(1, 10001))), + FrameData(numpy.append(numpy.zeros(15000), numpy.arange(1, 10001))), EndData(150000, EndReason.OK), ] diff --git a/tests/test_ioc.py b/tests/test_ioc.py index 977901d9..f7de82bc 100644 --- a/tests/test_ioc.py +++ b/tests/test_ioc.py @@ -2,10 +2,9 @@ import logging from pathlib import Path from typing import Dict, Tuple +from unittest.mock import AsyncMock, patch import pytest -from fixtures.mocked_panda import TEST_PREFIX -from mock import AsyncMock, patch from mock.mock import MagicMock, call from pandablocks.asyncio import AsyncioClient from pandablocks.commands import GetLine, Put @@ -26,6 +25,7 @@ ) from softioc import builder, fields +from fixtures.mocked_panda import TEST_PREFIX from pandablocks_ioc._pvi import PviGroup from pandablocks_ioc._types import ( ONAM_STR, diff --git a/tests/test_ioc_system.py b/tests/test_ioc_system.py index bab4d673..f56c5713 100644 --- a/tests/test_ioc_system.py +++ b/tests/test_ioc_system.py @@ -5,15 +5,6 @@ import numpy import pytest from aioca import DBR_CHAR_STR, CANothing, caget, camonitor, caput -from fixtures.mocked_panda import ( - BOBFILE_DIR, - TEST_PREFIX, - TIMEOUT, - MockedAsyncioClient, - ResponseHandler, - command_to_key, - multiprocessing_queue_to_list, -) from numpy import ndarray from pandablocks.commands import Arm, Disarm, Put from pandablocks.responses import ( @@ -24,6 +15,15 @@ ) from pvi.device import SignalX +from fixtures.mocked_panda import ( + BOBFILE_DIR, + TEST_PREFIX, + TIMEOUT, + MockedAsyncioClient, + ResponseHandler, + command_to_key, + multiprocessing_queue_to_list, +) from pandablocks_ioc._pvi import Pvi, PviGroup from pandablocks_ioc._types import EpicsName from pandablocks_ioc.ioc import _BlockAndFieldInfo, introspect_panda @@ -115,7 +115,7 @@ async def test_create_softioc_system( pcap1_label = await caget(test_prefix + ":PCAP:LABEL") assert numpy.array_equal( pcap1_label, - numpy.array(list("PcapMetadataLabel".encode() + b"\0"), dtype=numpy.uint8), + numpy.array(list(b"PcapMetadataLabel" + b"\0"), dtype=numpy.uint8), ) diff --git a/tests/test_pvaccess.py b/tests/test_pvaccess.py index 1454c566..ed866b2b 100644 --- a/tests/test_pvaccess.py +++ b/tests/test_pvaccess.py @@ -3,10 +3,10 @@ from typing import OrderedDict import numpy -from fixtures.mocked_panda import TIMEOUT from numpy import ndarray from p4p.client.asyncio import Context +from fixtures.mocked_panda import TIMEOUT from pandablocks_ioc._types import EpicsName diff --git a/tests/test_tables.py b/tests/test_tables.py index adf105c7..78fd812c 100644 --- a/tests/test_tables.py +++ b/tests/test_tables.py @@ -1,13 +1,12 @@ import asyncio import typing from typing import Dict, List +from unittest.mock import AsyncMock import numpy import numpy.testing import pytest from aioca import caget, camonitor, caput -from fixtures.mocked_panda import TIMEOUT, command_to_key, multiprocessing_queue_to_list -from mock import AsyncMock from mock.mock import MagicMock, PropertyMock from numpy import ndarray from pandablocks.asyncio import AsyncioClient @@ -15,6 +14,7 @@ from pandablocks.responses import TableFieldDetails, TableFieldInfo from softioc import alarm +from fixtures.mocked_panda import TIMEOUT, command_to_key, multiprocessing_queue_to_list from pandablocks_ioc._tables import ( TableFieldRecordContainer, TableModeEnum, @@ -433,7 +433,7 @@ async def test_table_updater_update_mode_other( table_updater.client.send.assert_not_called() # Confirm each record was not called - for field_name, data in table_unpacked_data.items(): + for field_name, _ in table_unpacked_data.items(): record_info = table_updater.table_fields_records[field_name].record_info assert record_info @@ -479,7 +479,7 @@ def test_table_updater_update_table_not_view( table_updater.mode_record_info.record.get.assert_called_once() # Confirm the records were not called - for field_name, data in table_unpacked_data.items(): + for field_name, _ in table_unpacked_data.items(): # Note table_unpacked_data is deliberately in a different order to the sorted # data, hence use this lookup mechanism instead record_info = table_updater.table_fields_records[field_name].record_info