Skip to content

Commit 8300994

Browse files
committed
Fix command line tools not handling stdin/stdout pipes properly
1 parent 5fd122c commit 8300994

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tests/tools/test_network_backup_restore.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
CoroutineMock,
2222
BaseZStack1CC2531,
2323
BaseZStack3CC2531,
24+
FormedZStack1CC2531,
2425
BaseLaunchpadCC26X2R1,
2526
)
2627
from ..application.test_startup import DEV_NETWORK_SETTINGS
@@ -118,6 +119,17 @@ async def test_network_backup_empty(device, make_znp_server):
118119
await network_backup([znp_server._port_path, "-o", "-"])
119120

120121

122+
@pytest.mark.parametrize("device", [FormedZStack1CC2531])
123+
@pytest.mark.asyncio
124+
async def test_network_backup_pipe(device, make_znp_server, capsys):
125+
znp_server = make_znp_server(server_cls=device)
126+
127+
await network_backup([znp_server._port_path, "-o", "-"])
128+
stdout, stderr = capsys.readouterr()
129+
130+
validate_backup_json(json.loads(stdout))
131+
132+
121133
@pytest.mark.parametrize("device", FORMED_DEVICES)
122134
@pytest.mark.asyncio
123135
async def test_network_backup_formed(device, make_znp_server, tmp_path):

zigpy_znp/tools/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def close(self):
155155
return
156156

157157
def __enter__(self):
158-
return
158+
return self
159159

160160
def __exit__(self, exc_type, exc_value, traceback):
161161
return

0 commit comments

Comments
 (0)