|
1 | 1 | import asyncio |
| 2 | +from unittest.mock import patch |
2 | 3 |
|
3 | 4 | import pytest |
4 | 5 |
|
5 | 6 | import zigpy_znp.config as conf |
6 | 7 | from zigpy_znp.uart import connect as uart_connect |
7 | 8 | from zigpy_znp.zigbee.application import ControllerApplication |
8 | 9 |
|
9 | | -from ..conftest import FORMED_DEVICES, FormedLaunchpadCC26X2R1, swap_attribute |
| 10 | +from ..conftest import FORMED_DEVICES, FormedLaunchpadCC26X2R1 |
10 | 11 |
|
11 | 12 |
|
12 | 13 | async def test_no_double_connect(make_znp_server, mocker): |
@@ -118,7 +119,7 @@ async def test_reconnect(device, event_loop, make_application): |
118 | 119 | assert app._znp is not None |
119 | 120 |
|
120 | 121 | # Don't reply to anything for a bit |
121 | | - with swap_attribute(znp_server, "frame_received", lambda _: None): |
| 122 | + with patch.object(znp_server, "frame_received", lambda _: None): |
122 | 123 | # Now that we're connected, have the server close the connection |
123 | 124 | znp_server._uart._transport.close() |
124 | 125 |
|
@@ -197,7 +198,7 @@ async def test_reconnect_lockup(device, event_loop, make_application, mocker): |
197 | 198 | await app.startup(auto_form=False) |
198 | 199 |
|
199 | 200 | # Stop responding |
200 | | - with swap_attribute(znp_server, "frame_received", lambda _: None): |
| 201 | + with patch.object(znp_server, "frame_received", lambda _: None): |
201 | 202 | assert app._znp is not None |
202 | 203 | assert app._reconnect_task.done() |
203 | 204 |
|
@@ -250,7 +251,7 @@ async def patched_load_network_info(old_load=app.load_network_info, **kwargs): |
250 | 251 | finally: |
251 | 252 | did_load_info.set_result(True) |
252 | 253 |
|
253 | | - with swap_attribute(app, "load_network_info", patched_load_network_info): |
| 254 | + with patch.object(app, "load_network_info", patched_load_network_info): |
254 | 255 | # "Drop" the connection like PySerial |
255 | 256 | app._znp._uart.connection_lost(exc=None) |
256 | 257 |
|
|
0 commit comments