Skip to content

Commit d750b61

Browse files
authored
Fix warnings in tests (#267)
1 parent 46cf8af commit d750b61

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ addopts = """
9191
"""
9292
# https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings
9393
# https://github.com/DiamondLightSource/FastCS/issues/230
94-
# filterwarnings = "error"
94+
filterwarnings = "error"
9595
# Doctest python code in docs, python code in src docstrings, test functions in tests
9696
testpaths = "docs src tests"
9797
timeout = 1

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import io
23
import multiprocessing
34
import os
@@ -236,3 +237,11 @@ def test_controller(tango_system, register_device):
236237

237238
process.send_signal(signal.SIGINT)
238239
process.wait(timeout)
240+
241+
242+
@pytest.fixture
243+
def event_loop():
244+
loop = asyncio.new_event_loop()
245+
yield loop
246+
loop.run_until_complete(loop.shutdown_asyncgens())
247+
loop.close()

tests/test_launch.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ def test_error_if_identical_context_in_transports(mocker: MockerFixture, data):
154154
new_callable=mocker.PropertyMock,
155155
return_value={"controller": "test"},
156156
)
157+
mocker.patch(
158+
"fastcs.transport.epics.pva.transport.EpicsPVATransport.serve",
159+
new_callable=mocker.PropertyMock,
160+
)
161+
mocker.patch(
162+
"fastcs.transport.epics.ca.transport.EpicsCATransport.serve",
163+
new_callable=mocker.PropertyMock,
164+
)
157165
app = _launch(IsHinted)
158166
result = runner.invoke(app, ["run", str(data / "config.yaml")])
159167
assert isinstance(result.exception, RuntimeError)

tests/transport/tango/test_dsr.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def create_test_context(tango_controller_api: AssertableControllerAPI):
5050
tango_transport = TangoTransport()
5151
tango_transport.connect(
5252
tango_controller_api,
53-
# This is passed to enable instantiating the transport, but tests must avoid
54-
# using via patching of functions. It will raise NotImplementedError if used.
55-
asyncio.AbstractEventLoop(),
53+
asyncio.get_event_loop(),
5654
)
5755
device = tango_transport._dsr._device
5856
# https://tango-controls.readthedocs.io/projects/pytango/en/v9.5.1/testing/test_context.html

0 commit comments

Comments
 (0)