Skip to content

Commit

Permalink
Fix order
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Sep 10, 2024
1 parent 3ebea11 commit bf66f7f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/contrib/filesystem/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,24 @@ def test_directory_list_contents(tmp_path: pathlib.Path):
"""Test listing a directory."""

# Create a directory with a file and a root-level file
dirpath = tmp_path / "test"
(tmp_path / "a.txt").write_text("Hello from the root!")
dirpath = tmp_path / "b"
dirpath.mkdir()
(dirpath / "file.txt").write_text("Hello from a directory!")
(tmp_path / "file.txt").write_text("Hello from the root!")
(dirpath / "c.txt").write_text("Hello from a directory!")

directory = local.LocalDirectory(tmp_path)
contents = list(directory.list_contents())
assert len(contents) == 3

root_file, directory, nested_file = contents
# Get the root file, the directory, and the nested file regardless of order
root_file, directory, nested_file = sorted(contents, key=lambda x: x.path.name)
assert isinstance(root_file, local.LocalFile)
assert root_file.path.name == "file.txt"
assert root_file.path.name == "a.txt"
assert root_file.read_text() == "Hello from the root!"

assert isinstance(directory, local.LocalDirectory)
assert directory.path.name == "test"
assert directory.path.name == "b"

assert isinstance(nested_file, local.LocalFile)
assert nested_file.path.name == "file.txt"
assert nested_file.path.name == "c.txt"
assert nested_file.read_text() == "Hello from a directory!"

0 comments on commit bf66f7f

Please sign in to comment.