mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-10 09:25:57 +00:00
test: fix flaky tests relying on /nonexistent/... path under container root
Two tests in this module (test_returns_none_on_invalid_path and test_fallback_when_disk_write_fails) used paths like '/nonexistent/impossible/path' to trigger _externalize's OSError fallback. These paths are creatable when the test process runs as root inside the CI container: os.makedirs(..., exist_ok=True) successfully creates the entire chain under /, so the OSError branch is never hit and the tests fail. Reproducible on main independently of this PR. Switch to '/dev/null/cannot-mkdir-here'. /dev/null is a character device on both Linux and macOS, so os.makedirs always fails with NotADirectoryError regardless of privileges, reliably exercising the OSError fallback.
This commit is contained in:
@@ -121,11 +121,17 @@ class TestExternalize:
|
||||
assert f.read() == "full content here"
|
||||
|
||||
def test_returns_none_on_invalid_path(self):
|
||||
# ``/dev/null`` is a character device on both Linux and macOS, so
|
||||
# ``os.makedirs`` cannot create any subdirectory under it for any
|
||||
# user (including root). The previously-used ``/nonexistent/...``
|
||||
# path was silently created by ``mkdir -p`` when the test process
|
||||
# ran as root inside the CI container, which made this test fail
|
||||
# in CI independently of the externalization logic under test.
|
||||
path = _externalize(
|
||||
"data",
|
||||
tool_name="test",
|
||||
tool_call_id="tc-1",
|
||||
outputs_path="/nonexistent/path/that/should/not/exist",
|
||||
outputs_path="/dev/null/cannot-mkdir-here",
|
||||
storage_subdir=".tool-results",
|
||||
)
|
||||
assert path is None
|
||||
@@ -370,7 +376,7 @@ class TestWrapToolCallFallback:
|
||||
mw = ToolOutputBudgetMiddleware(config=config)
|
||||
content = "x" * 500
|
||||
msg = _tm(content, name="tool")
|
||||
req = _make_request(outputs_path="/nonexistent/impossible/path")
|
||||
req = _make_request(outputs_path="/dev/null/cannot-mkdir-here")
|
||||
|
||||
result = mw.wrap_tool_call(req, lambda _: msg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user