Skip to content

Commit 993caff

Browse files
author
Your Name
committed
Fix tests to account for CI/CD pipeline drives
1 parent d52e51e commit 993caff

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

tests/tools/test_read_range_execute.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../.."))
1717

1818

19+
def _safe_relpath(path):
20+
"""Wrapper around os.path.relpath that handles cross-drive scenarios on Windows."""
21+
try:
22+
return os.path.relpath(path)
23+
except ValueError:
24+
# On Windows, os.path.relpath fails when path and cwd are on different drives.
25+
# Fall back to basename which is sufficient for test patches.
26+
return os.path.basename(path)
27+
28+
1929
# =============================================================================
2030
# Fixtures
2131
# =============================================================================
@@ -27,7 +37,7 @@ def mock_coder():
2737
coder = MagicMock()
2838
coder.turn_count = 5
2939
coder.abs_root_path.side_effect = lambda p: os.path.abspath(p)
30-
coder.get_rel_fname.side_effect = lambda p: os.path.relpath(p, os.getcwd())
40+
coder.get_rel_fname.side_effect = lambda p: _safe_relpath(p)
3141
coder.io.tool_output = MagicMock()
3242
coder.io.tool_error = MagicMock()
3343
coder.io.tool_warning = MagicMock()
@@ -114,7 +124,7 @@ def _setup(self, mock_coder, mock_file_context, mock_chunks, mock_manager, file_
114124
# Patch resolve_paths
115125
rp_patch = patch(
116126
"cecli.tools.read_range.resolve_paths",
117-
return_value=(self.test_file, os.path.relpath(self.test_file)),
127+
return_value=(self.test_file, _safe_relpath(self.test_file)),
118128
)
119129
rp_patch.start()
120130
self.patches.append(rp_patch)

0 commit comments

Comments
 (0)