diff --git a/pyproject.toml b/pyproject.toml index a6ccbc4d6..e2e962719 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,7 +91,7 @@ addopts = """ """ # https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings # https://github.com/DiamondLightSource/FastCS/issues/230 -# filterwarnings = "error" +filterwarnings = "error" # Doctest python code in docs, python code in src docstrings, test functions in tests testpaths = "docs src tests" timeout = 1 diff --git a/tests/conftest.py b/tests/conftest.py index f6770d5e9..21373247e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +import asyncio import io import multiprocessing import os @@ -236,3 +237,11 @@ def test_controller(tango_system, register_device): process.send_signal(signal.SIGINT) process.wait(timeout) + + +@pytest.fixture +def event_loop(): + loop = asyncio.new_event_loop() + yield loop + loop.run_until_complete(loop.shutdown_asyncgens()) + loop.close() diff --git a/tests/test_launch.py b/tests/test_launch.py index 36c505280..883fcdb9c 100644 --- a/tests/test_launch.py +++ b/tests/test_launch.py @@ -154,6 +154,14 @@ def test_error_if_identical_context_in_transports(mocker: MockerFixture, data): new_callable=mocker.PropertyMock, return_value={"controller": "test"}, ) + mocker.patch( + "fastcs.transport.epics.pva.transport.EpicsPVATransport.serve", + new_callable=mocker.PropertyMock, + ) + mocker.patch( + "fastcs.transport.epics.ca.transport.EpicsCATransport.serve", + new_callable=mocker.PropertyMock, + ) app = _launch(IsHinted) result = runner.invoke(app, ["run", str(data / "config.yaml")]) assert isinstance(result.exception, RuntimeError) diff --git a/tests/transport/tango/test_dsr.py b/tests/transport/tango/test_dsr.py index 4883601f9..449732853 100644 --- a/tests/transport/tango/test_dsr.py +++ b/tests/transport/tango/test_dsr.py @@ -50,9 +50,7 @@ def create_test_context(tango_controller_api: AssertableControllerAPI): tango_transport = TangoTransport() tango_transport.connect( tango_controller_api, - # This is passed to enable instantiating the transport, but tests must avoid - # using via patching of functions. It will raise NotImplementedError if used. - asyncio.AbstractEventLoop(), + asyncio.get_event_loop(), ) device = tango_transport._dsr._device # https://tango-controls.readthedocs.io/projects/pytango/en/v9.5.1/testing/test_context.html