Skip to content

Commit 6bd7438

Browse files
committed
test(stdio): specify encoding in file operations to satisfy warn_default_encoding
1 parent eae718c commit 6bd7438

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tests/client/test_stdio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ async def test_preexec_fn_executes_in_child_process(tmp_path: Path) -> None:
14681468
log_file = tmp_path / "preexec.log"
14691469

14701470
def hook() -> None:
1471-
with open(log_file, "w") as f:
1471+
with open(log_file, "w", encoding="utf-8") as f:
14721472
f.write(f"{os.getpid()}")
14731473

14741474
server_params = StdioServerParameters(
@@ -1481,7 +1481,7 @@ def hook() -> None:
14811481
async with stdio_client(server_params):
14821482
while not log_file.exists():
14831483
await anyio.sleep(0.01)
1484-
child_pid = int(log_file.read_text().strip())
1484+
child_pid = int(log_file.read_text(encoding="utf-8").strip())
14851485
assert child_pid != os.getpid()
14861486

14871487

@@ -1492,7 +1492,7 @@ async def test_process_group_sets_child_process_group(tmp_path: Path) -> None:
14921492
pgid_file = tmp_path / "pgid.log"
14931493
script = (
14941494
f"import os, pathlib, sys\n"
1495-
f"pathlib.Path({str(pgid_file)!r}).write_text(f'{{os.getpid()}}:{{os.getpgrp()}}')\n"
1495+
f"pathlib.Path({str(pgid_file)!r}).write_text(f'{{os.getpid()}}:{{os.getpgrp()}}', encoding='utf-8')\n"
14961496
f"sys.stdin.read()\n"
14971497
)
14981498
server_params = StdioServerParameters(
@@ -1505,6 +1505,6 @@ async def test_process_group_sets_child_process_group(tmp_path: Path) -> None:
15051505
async with stdio_client(server_params):
15061506
while not pgid_file.exists():
15071507
await anyio.sleep(0.01)
1508-
pid_str, pgid_str = pgid_file.read_text().strip().split(":")
1508+
pid_str, pgid_str = pgid_file.read_text(encoding="utf-8").strip().split(":")
15091509
assert pid_str == pgid_str
15101510
assert int(pid_str) != os.getpid()

0 commit comments

Comments
 (0)