Skip to content

Commit a883fff

Browse files
committed
tests/test_cli: fix leaking file descriptor
Ensure opened file is closed before the test ends.
1 parent 6c5d53b commit a883fff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/test_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def test_download_ble(self):
8282
# Create args
8383
args = argparse.Namespace(
8484
conntype="ble",
85-
file=open(temp_path, "r", encoding="utf-8"),
85+
file=stack.enter_context(open(temp_path, "r", encoding="utf-8")),
8686
name="MyHub",
8787
start=False,
8888
wait=False,
@@ -131,7 +131,7 @@ async def test_download_usb(self):
131131
# Create args
132132
args = argparse.Namespace(
133133
conntype="usb",
134-
file=open(temp_path, "r", encoding="utf-8"),
134+
file=stack.enter_context(open(temp_path, "r", encoding="utf-8")),
135135
name=None,
136136
start=False,
137137
wait=False,
@@ -223,7 +223,7 @@ async def test_download_connection_error(self):
223223
# Create args
224224
args = argparse.Namespace(
225225
conntype="ble",
226-
file=open(temp_path, "r", encoding="utf-8"),
226+
file=stack.enter_context(open(temp_path, "r", encoding="utf-8")),
227227
name="MyHub",
228228
start=False,
229229
wait=False,

0 commit comments

Comments
 (0)