Skip to content

Commit 8e14c39

Browse files
committed
Bump test dependencies and replace uses of no-op patch with spy
1 parent e4e9f54 commit 8e14c39

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
],
2929
tests_require=[
3030
"asynctest",
31-
"pytest==5.3.5",
32-
"pytest-asyncio==0.10.0",
33-
"asyncmock",
31+
"pytest>=5.4.5",
32+
"pytest-asyncio>=0.12.0",
3433
"pytest-mock",
3534
],
3635
)

tests/test_application.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
import pytest
55

6-
from asynctest import CoroutineMock
6+
try:
7+
# Python 3.8 already has this
8+
from mock import AsyncMock as CoroutineMock
9+
except ImportError:
10+
from asynctest import CoroutineMock
711

812
import zigpy
913
import zigpy_znp.types as t
@@ -770,9 +774,7 @@ async def test_zigpy_request_failure(application, mocker):
770774
],
771775
)
772776

773-
mocker.patch.object(
774-
app, "_send_request", new=CoroutineMock(wraps=app._send_request)
775-
)
777+
mocker.spy(app, "_send_request")
776778

777779
# Fail to turn on the light
778780
with pytest.raises(zigpy.exceptions.DeliveryError):
@@ -793,21 +795,21 @@ async def test_request_use_ieee(application, mocker, use_ieee, dev_addr):
793795
app, znp_server = application
794796
device = app.add_device(ieee=t.EUI64(range(8)), nwk=0xAABB)
795797

796-
send_req = mocker.patch.object(app, "_send_request", new=CoroutineMock())
798+
mocker.patch.object(app, "_send_request", new=CoroutineMock())
797799

798800
await app.request(
799801
device,
800802
use_ieee=use_ieee,
801-
profile=None,
802-
cluster=None,
803-
src_ep=None,
804-
dst_ep=None,
805-
sequence=None,
806-
data=None,
803+
profile=1,
804+
cluster=2,
805+
src_ep=3,
806+
dst_ep=4,
807+
sequence=5,
808+
data=b"6",
807809
)
808810

809-
assert send_req.call_count == 1
810-
assert send_req.mock_calls[0][2]["dst_addr"] == dev_addr
811+
assert app._send_request.call_count == 1
812+
assert app._send_request.mock_calls[0][2]["dst_addr"] == dev_addr
811813

812814

813815
@pytest_mark_asyncio_timeout(seconds=3)
@@ -831,7 +833,7 @@ async def test_update_network(mocker, caplog, application):
831833
app, znp_server = application
832834

833835
await app.startup(auto_form=False)
834-
mocker.patch.object(app, "_reset", new=CoroutineMock())
836+
mocker.spy(app, "_reset")
835837

836838
channel = t.uint8_t(15)
837839
pan_id = t.PanId(0x1234)
@@ -974,7 +976,7 @@ async def test_force_remove(application, mocker):
974976
async def test_auto_form_unnecessary(application, mocker):
975977
app, znp_server = application
976978

977-
mocker.patch.object(app, "form_network")
979+
mocker.patch.object(app, "form_network", new=CoroutineMock())
978980

979981
await app.startup(auto_form=True)
980982
assert app.form_network.call_count == 0
@@ -986,7 +988,7 @@ async def test_auto_form_necessary(application, mocker):
986988
nvram = {}
987989

988990
mocker.patch.object(app, "update_network", new=CoroutineMock())
989-
mocker.patch.object(app, "_reset", new=CoroutineMock())
991+
mocker.spy(app, "_reset")
990992

991993
def nvram_writer(req):
992994
nvram[req.Id] = req.Value

0 commit comments

Comments
 (0)