Skip to content

Commit 06709f1

Browse files
committed
added a BaseEventLoop to the mocked_time_record_updater since it will give a deprecation warning on python 3.10 if you don't
1 parent d1917d8 commit 06709f1

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

Diff for: tests/fixtures/mocked_panda.py

+21-17
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,27 @@ def mocked_time_record_updater():
6060

6161
# We don't have AsyncMock in Python3.7, so do it ourselves
6262
client = MagicMock()
63-
f = asyncio.Future()
64-
f.set_result("8e-09")
65-
client.send.return_value = f
66-
67-
mocked_record_info = MagicMock()
68-
mocked_record_info.record = MagicMock()
69-
mocked_record_info.record.name = EpicsName(TEST_PREFIX + ":TEST:STR")
70-
71-
return _TimeRecordUpdater(
72-
mocked_record_info,
73-
client,
74-
{},
75-
["TEST1", "TEST2", "TEST3"],
76-
base_record,
77-
TEST_PREFIX,
78-
True,
79-
)
63+
loop = asyncio.BaseEventLoop()
64+
try:
65+
f = asyncio.Future(loop=loop)
66+
f.set_result("8e-09")
67+
client.send.return_value = f
68+
69+
mocked_record_info = MagicMock()
70+
mocked_record_info.record = MagicMock()
71+
mocked_record_info.record.name = EpicsName(TEST_PREFIX + ":TEST:STR")
72+
73+
yield _TimeRecordUpdater(
74+
mocked_record_info,
75+
client,
76+
{},
77+
["TEST1", "TEST2", "TEST3"],
78+
base_record,
79+
TEST_PREFIX,
80+
True,
81+
)
82+
finally:
83+
loop.close()
8084

8185

8286
@pytest.fixture

Diff for: tests/test_ioc.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,9 @@ def test_create_record_info_value_error(
642642
@patch("pandablocks_ioc.ioc.db_put_field")
643643
@pytest.mark.parametrize("new_val", ["TEST2", 2])
644644
async def test_time_record_updater_update_egu(
645-
db_put_field: MagicMock, mocked_time_record_updater: _TimeRecordUpdater, new_val
645+
db_put_field: MagicMock,
646+
mocked_time_record_updater: _TimeRecordUpdater,
647+
new_val,
646648
):
647649
mocked_time_record_updater.update_egu(new_val)
648650
db_put_field.assert_called_once()

Diff for: tests/test_ioc_system.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,20 @@ async def test_create_softioc_time_panda_changes(mocked_panda_standard_responses
193193
try:
194194
# Set up monitors for expected changes when the UNITS are changed,
195195
# and check the initial values are correct
196-
egu_queue: asyncio.Queue = asyncio.Queue()
196+
egu_queue = asyncio.Queue()
197197
m1 = camonitor(
198198
TEST_PREFIX + ":PULSE1:DELAY.EGU",
199199
egu_queue.put,
200200
)
201201
assert await asyncio.wait_for(egu_queue.get(), TIMEOUT) == "ms"
202202

203-
units_queue: asyncio.Queue = asyncio.Queue()
203+
units_queue = asyncio.Queue()
204204
m2 = camonitor(
205205
TEST_PREFIX + ":PULSE1:DELAY:UNITS", units_queue.put, datatype=str
206206
)
207207
assert await asyncio.wait_for(units_queue.get(), TIMEOUT) == "ms"
208208

209-
drvl_queue: asyncio.Queue = asyncio.Queue()
209+
drvl_queue = asyncio.Queue()
210210
m3 = camonitor(
211211
TEST_PREFIX + ":PULSE1:DELAY.DRVL",
212212
drvl_queue.put,

0 commit comments

Comments
 (0)