diff --git a/src/fastcs/transport/epics/ioc.py b/src/fastcs/transport/epics/ioc.py index f4bebb8..0d70632 100644 --- a/src/fastcs/transport/epics/ioc.py +++ b/src/fastcs/transport/epics/ioc.py @@ -1,5 +1,4 @@ import asyncio -import warnings from collections.abc import Callable from types import MethodType from typing import Any, Literal diff --git a/src/fastcs/transport/tango/dsr.py b/src/fastcs/transport/tango/dsr.py index f38c56e..0e0d62b 100644 --- a/src/fastcs/transport/tango/dsr.py +++ b/src/fastcs/transport/tango/dsr.py @@ -32,14 +32,6 @@ async def fget(tango_device: Device): return fget -def _tango_display_format(attribute: Attribute) -> str: - match attribute.datatype: - case Float(prec): - return f"%.{prec}" - - return "6.2f" # `tango.server.attribute` default for `format` - - async def _run_threadsafe_blocking( coro: Coroutine[Any, Any, Any], loop: asyncio.AbstractEventLoop ) -> None: @@ -59,9 +51,9 @@ def _wrap_updater_fset( ) -> Callable[[Any, Any], Any]: cast_method = get_cast_method_from_tango_type(attribute.datatype) - async def fset(tango_device: Device, val): + async def fset(tango_device: Device, value): tango_device.info_stream(f"called fset method: {attr_name}") - coro = attribute.process(val) + coro = attribute.process(cast_method(value)) await _run_threadsafe_blocking(coro, loop) return fset diff --git a/tests/conftest.py b/tests/conftest.py index acf8619..7169c80 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,14 +10,9 @@ import pytest from aioca import purge_channel_caches -from fastcs.attributes import AttrR, AttrRW, AttrW, Handler, Sender, Updater -from fastcs.controller import Controller, SubController -from fastcs.datatypes import Bool, Float, Int, String -from fastcs.transport.tango.dsr import register_dev -from fastcs.datatypes import Bool, Enum, Float, Int, String, WaveForm -from fastcs.wrappers import command, scan from fastcs.attributes import AttrR, AttrRW, AttrW from fastcs.datatypes import Bool, Float, Int, String +from fastcs.transport.tango.dsr import register_dev from tests.assertable_controller import ( TestController, TestHandler, diff --git a/tests/transport/tango/test_dsr.py b/tests/transport/tango/test_dsr.py index 374664f..13f03c0 100644 --- a/tests/transport/tango/test_dsr.py +++ b/tests/transport/tango/test_dsr.py @@ -1,7 +1,6 @@ import asyncio -from unittest import mock - import enum +from unittest import mock import numpy as np import pytest @@ -22,6 +21,8 @@ async def patch_run_threadsafe_blocking(coro, loop): await coro + + class TangoAssertableController(AssertableController): read_int = AttrR(Int(), handler=TestUpdater()) read_write_int = AttrRW(Int(), handler=TestHandler()) @@ -34,6 +35,11 @@ class TangoAssertableController(AssertableController): two_d_waveform = AttrRW(WaveForm(np.int32, (10, 10))) +@pytest.fixture(scope="class") +def assertable_controller(class_mocker: MockerFixture): + return TangoAssertableController(class_mocker) + + class TestTangoDevice: @pytest.fixture(scope="class") def tango_context(self, assertable_controller):