Skip to content

Commit aa90387

Browse files
committed
Add tests for as_local tmpdir
1 parent f7f22cc commit aa90387

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

python/lsst/resources/tests.py

+13
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,19 @@ def test_local(self) -> None:
794794
with self.root_uri.as_local() as local_uri:
795795
pass
796796

797+
if not src.isLocal:
798+
# as_local tmpdir can not be a remote resource.
799+
with self.assertRaises(ValueError):
800+
with src.as_local(tmpdir=self.root_uri) as local_uri:
801+
pass
802+
803+
# tmpdir is ignored for local file.
804+
with tempfile.TemporaryDirectory() as tmpdir:
805+
temp_dir = ResourcePath(tmpdir, forceDirectory=True)
806+
with src.as_local(tmpdir=temp_dir) as local_uri:
807+
self.assertEqual(local_uri.dirname(), temp_dir)
808+
self.assertTrue(local_uri.exists())
809+
797810
def test_local_mtransfer(self) -> None:
798811
"""Check that bulk transfer to/from local works."""
799812
# Create remote resources

0 commit comments

Comments
 (0)