Skip to content

Commit

Permalink
CLI: Fix test_cli_run on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Oct 26, 2024
1 parent 09dbf3b commit a301e33
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.pytest_cache
.DS_Store
coverage.xml
.coverage*

__pycache__
tests/__pycache__
Expand Down
8 changes: 6 additions & 2 deletions responder/util/cmd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ruff: noqa: S603, S607
import shutil
import subprocess
import sys
import threading
from pathlib import Path

Expand All @@ -12,9 +13,12 @@ class ResponderProgram:

@staticmethod
def path():
program = shutil.which("responder")
name = "responder"
if sys.platform == "win32":
name = "responder.exe"
program = shutil.which(name)
if program is None:
raise RuntimeError("Could not find 'responder' executable in PATH")
raise RuntimeError(f"Could not find '{name}' executable in PATH")
return program

@classmethod
Expand Down
5 changes: 2 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ def test_cli_run(capfd):
# Invoke `responder run`.
# Start a Responder service instance in the background, using its CLI.
# Make it terminate itself after serving one HTTP request.
server = ResponderServer(
target="examples/helloworld.py", port=random_port(), limit_max_requests=1
)
target = Path("examples") / "helloworld.py"
server = ResponderServer(target=str(target), port=random_port(), limit_max_requests=1)
try:
server.start()
wait_server(server.port)
Expand Down

0 comments on commit a301e33

Please sign in to comment.