|
8 | 8 | """ |
9 | 9 |
|
10 | 10 | import io |
| 11 | +import tempfile |
11 | 12 | from pathlib import Path |
12 | 13 | from typing import IO, Any, AnyStr, Callable, List, Optional, Tuple, Union, cast |
13 | 14 |
|
|
22 | 23 | from robotcode.repl.console_interpreter import ConsoleInterpreter |
23 | 24 | from robotcode.robot.utils import RF_VERSION |
24 | 25 |
|
25 | | -_SOURCE = "/tmp/dbg_console_suite.robot" |
| 26 | +# A writable temp path (not a hardcoded "/tmp/…", which is not writable on Windows). |
| 27 | +_SOURCE = str(Path(tempfile.gettempdir()) / "dbg_console_suite.robot") |
26 | 28 |
|
27 | 29 | # 11 = `Log before`, 12 = `Outer` |
28 | 30 | STEP_SUITE = """\ |
@@ -464,7 +466,7 @@ def test_break_with_path_line_format_triggers() -> None: |
464 | 466 | assert len(stops) == 2 |
465 | 467 | assert stops[0].startswith("* entry") |
466 | 468 | # The location is shown relative to the cwd (a `…/`-prefixed path here, since |
467 | | - # the test source lives under /tmp); assert the filename:line suffix, which |
| 469 | + # the test source lives in a temp dir); assert the filename:line suffix, which |
468 | 470 | # is stable regardless of where the tests run from. |
469 | 471 | assert "dbg_console_suite.robot:12)" in stops[1] # the line breakpoint fired |
470 | 472 |
|
@@ -939,7 +941,9 @@ def test_source_suite_local_keyword_not_resolved() -> None: |
939 | 941 | def test_source_resource_keyword(tmp_path: Path) -> None: |
940 | 942 | res = tmp_path / "kw.resource" |
941 | 943 | res.write_text("*** Keywords ***\nCustom Step\n Log hi\n", encoding="utf-8") |
942 | | - suite_text = f"*** Settings ***\nResource {res}\n\n*** Test Cases ***\nT\n Custom Step\n" |
| 944 | + # Forward slashes: a raw Windows path (backslashes) in .robot source would be |
| 945 | + # mangled by Robot's escape handling, so the resource import would fail. |
| 946 | + suite_text = f"*** Settings ***\nResource {res.as_posix()}\n\n*** Test Cases ***\nT\n Custom Step\n" |
943 | 947 | messages = _run_debug(suite_text, [".source Custom Step", ".continue"], stop_on_entry=True) |
944 | 948 | assert any(m.startswith("Custom Step (") and "kw.resource:" in m for m in messages) |
945 | 949 | assert any(m.lstrip().startswith("->") for m in messages) |
|
0 commit comments