Skip to content

Commit fad49ab

Browse files
committed
Use an async ssh client in test_gambaterm_ssh
1 parent 58758e2 commit fad49ab

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,5 @@ test-requires = "pytest"
9393
test-command = "pytest {project}/tests -v -k 'test_gambaterm[non-interactive]'"
9494

9595
[tool.cibuildwheel.linux]
96-
before-all = "yum install -y openssh-clients"
9796
test-requires = "pytest"
9897
test-command = "pytest {project}/tests -v"

tests/test_gambaterm.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,24 @@ def test_gambaterm_ssh(ssh_config: Path, gambaterm_config: Path) -> None:
7171
)
7272
assert server.stdout.readline() == "Running SSH server on 127.0.0.1:8022...\n"
7373
assert (gambaterm_config / "ssh_host_key").exists()
74-
client = Popen(
75-
f"ssh -tt -q localhost -p 8022 -i {ssh_config / 'id_rsa'} -o StrictHostKeyChecking=no",
76-
shell=True,
77-
stdin=PIPE,
78-
stdout=PIPE,
79-
stderr=PIPE,
80-
text=True,
81-
env={**os.environ, "TERM": "xterm-256color"},
82-
)
83-
assert client.stdout is not None
84-
assert client.stderr is not None
85-
client.wait(timeout=5)
86-
client_stdout = client.stdout.read()
87-
client_stderr = client.stderr.read()
88-
assert client.returncode == 0
89-
assert client_stderr == ""
74+
75+
async def ssh_client() -> str:
76+
async with asyncssh.connect(
77+
host="127.0.0.1",
78+
port=8022,
79+
client_keys=[str(ssh_config / "id_rsa")],
80+
known_hosts=None,
81+
username=os.environ.get("USER", "user"),
82+
) as conn:
83+
result = await conn.run(
84+
"",
85+
term_type="xterm-256color",
86+
term_size=(80, 24),
87+
)
88+
assert isinstance(result.stdout, str)
89+
return result.stdout
90+
91+
client_stdout = asyncio.run(ssh_client())
9092
assert "| test_rom.gb |" in client_stdout
9193
if sys.platform == "linux":
9294
assert "▀ ▄▄ ▀" in client_stdout

0 commit comments

Comments
 (0)