Skip to content

Commit be27d4c

Browse files
committed
test(discover): use platform-agnostic tmp paths in error tests
The two `discover` error tests hardcoded `/tmp` as a Unix path, which breaks on Windows where the directory doesn't exist (`--root /tmp` is rejected by click before the actual assertion runs). Use pytest's `tmp_path` fixture instead so the tests work on Linux, macOS and Windows.
1 parent 3c47b48 commit be27d4c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

tests/robotcode/runner/cli/discover/test_errors.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
from .conftest import CliRunner
1212

1313

14-
def test_discover_tests_nonexistent_path(robotcode_cli: CliRunner) -> None:
14+
def test_discover_tests_nonexistent_path(robotcode_cli: CliRunner, tmp_path: Path) -> None:
1515
"""A path that doesn't exist on disk yields a non-zero exit."""
16-
result = robotcode_cli(["discover", "tests", "/tmp/no-such-dir-discover-tests"], expect_ok=False)
16+
missing = tmp_path / "no-such-dir-discover-tests"
17+
result = robotcode_cli(["discover", "tests", str(missing)], expect_ok=False)
1718
assert result.returncode != 0
1819

1920

20-
def test_discover_files_without_argument_errors(robotcode_cli: CliRunner) -> None:
21+
def test_discover_files_without_argument_errors(robotcode_cli: CliRunner, tmp_path: Path) -> None:
2122
"""`discover files` without PATHS argument and no default_paths config → UsageError."""
22-
result = robotcode_cli(["--root", "/tmp", "discover", "files"], expect_ok=False)
23+
result = robotcode_cli(["--root", str(tmp_path), "discover", "files"], expect_ok=False)
2324
assert result.returncode != 0
2425
assert "argument" in (result.stderr or result.stdout).lower()
2526

0 commit comments

Comments
 (0)