Skip to content

Commit

Permalink
Add test specifically for schemeless isdir()
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jan 17, 2024
1 parent 01521d2 commit 234c1af
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_schemeless.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ def test_creation(self) -> None:
with self.assertRaises(ValueError):
ResourcePath(relative, root=ResourcePath("resource://lsst.resources/something.txt"))

def test_isdir(self):
"""Test that isdir() can check the file system."""
# Get the relative path for the current test file.
file = ResourcePath(__file__)
cwd = ResourcePath(".")
f = ResourcePath(file.relative_to(cwd), forceAbsolute=False)

self.assertFalse(f.scheme)
self.assertTrue(f.exists())
self.assertIsNone(f.dirLike)
self.assertFalse(f.isdir())
self.assertIs(f.dirLike, False)

# Check that a file that does not exist does not update the dirLike
# flag.
f = ResourcePath("a/b/c_not_here.txt", forceAbsolute=False)
self.assertFalse(f.scheme)
self.assertFalse(f.isdir())
self.assertIsNone(f.dirLike)


if __name__ == "__main__":
unittest.main()

0 comments on commit 234c1af

Please sign in to comment.