Skip to content

Commit a2a8cc2

Browse files
shchekleinclaude
andcommitted
tests: make test_walk_root deterministic
The mock server exposes the host's real filesystem, so assertions about the contents of "/" depend on machine state: mock-ssh-server stats every entry of a listing, so a single dangling symlink at the host root fails the whole readdir, and fsspec's walk(on_error="omit") swallows the error, silently turning the name/exists assertions into a no-op. Assert only the yielded root, which distinguishes the fix (root "/") from the regression (root "") on every machine. Also correct the failure-mode note: most servers (e.g. OpenSSH) reject an empty path with ENOENT outside REALPATH; servers implementing the SFTP draft's empty-path rule resolve it to the default directory instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent d0bcbb3 commit a2a8cc2

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

tests/test_sshfs.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,14 @@ def test_walk(fs, remote_dir):
221221

222222
def test_walk_root(fs):
223223
# Regression: SSHFileSystem._strip_protocol("/") used to collapse the
224-
# root to "", so walk("/") listed the home directory and yielded
225-
# relative paths that were not considered to exist.
226-
root, dirs, files = next(iter(fs.walk("/", maxdepth=1, detail=True)))
224+
# root to "", so walk("/") resolved against the server's default
225+
# directory (or failed outright on servers such as OpenSSH that
226+
# reject empty paths outside REALPATH) and yielded root "" with
227+
# names relative to it. Only the yielded root is asserted here: the
228+
# mock server exposes the host's real filesystem, so the contents of
229+
# "/" are not this test's to control.
230+
root, _dirs, _files = next(fs.walk("/", maxdepth=1))
227231
assert root == "/"
228-
for info in dirs.values():
229-
assert info["name"].startswith("/")
230-
assert fs.exists(info["name"])
231232

232233

233234
def test_strip_protocol():

0 commit comments

Comments
 (0)