|
1 | 1 | # pyright: reportMissingParameterType=false |
2 | | -import asyncio |
3 | | -import sys |
4 | 2 | from contextlib import nullcontext |
5 | 3 | from unittest.mock import ANY, MagicMock, call, patch |
6 | 4 |
|
|
25 | 23 | ) |
26 | 24 | from tests.conftest import MOCK_PREFIX |
27 | 25 |
|
28 | | -if sys.version_info < (3, 11): |
29 | | - aio_timeout_error = asyncio.exceptions.TimeoutError |
30 | | -else: |
31 | | - aio_timeout_error = TimeoutError |
32 | | - |
33 | 26 |
|
34 | 27 | async def _make_block(clazz): |
35 | 28 | block = clazz(float, MOCK_PREFIX, "float_block") |
@@ -192,7 +185,7 @@ async def test_block_set_with_timeout(): |
192 | 185 |
|
193 | 186 | set_mock_value(block.readback, 10) |
194 | 187 |
|
195 | | - with pytest.raises(aio_timeout_error): |
| 188 | + with pytest.raises(TimeoutError): |
196 | 189 | await block.set(20) |
197 | 190 |
|
198 | 191 | func.assert_called_once_with(20, 10) |
@@ -234,7 +227,7 @@ async def test_block_set_waiting_for_global_moving_flag_timeout(): |
234 | 227 |
|
235 | 228 | set_mock_value(block.global_moving, True) |
236 | 229 | with patch("ibex_bluesky_core.devices.block.asyncio.sleep") as mock_aio_sleep: |
237 | | - with pytest.raises(aio_timeout_error): |
| 230 | + with pytest.raises(TimeoutError): |
238 | 231 | await block.set(10) |
239 | 232 | # Only check first call, as wait_for_value from ophyd_async gives us a few more... |
240 | 233 | assert mock_aio_sleep.mock_calls[0] == call(GLOBAL_MOVING_FLAG_PRE_WAIT) |
@@ -382,13 +375,13 @@ async def test_block_mot_set_outside_limits(mot_block): |
382 | 375 | async def test_block_failing_write(timeout_is_error): |
383 | 376 | block = await _block_with_write_config(BlockWriteConfig(timeout_is_error=timeout_is_error)) |
384 | 377 |
|
385 | | - get_mock_put(block.setpoint).side_effect = aio_timeout_error |
| 378 | + get_mock_put(block.setpoint).side_effect = TimeoutError |
386 | 379 |
|
387 | | - with pytest.raises(aio_timeout_error) if timeout_is_error else nullcontext(): |
| 380 | + with pytest.raises(TimeoutError) if timeout_is_error else nullcontext(): |
388 | 381 | await block.set(1) |
389 | 382 |
|
390 | 383 |
|
391 | 384 | async def test_block_failing_write_with_default_write_config(writable_block): |
392 | | - get_mock_put(writable_block.setpoint).side_effect = aio_timeout_error |
393 | | - with pytest.raises(aio_timeout_error): |
| 385 | + get_mock_put(writable_block.setpoint).side_effect = TimeoutError |
| 386 | + with pytest.raises(TimeoutError): |
394 | 387 | await writable_block.set(1) |
0 commit comments