Skip to content

Commit

Permalink
Merge pull request #50 from lsst/tickets/DM-38552-hotfix
Browse files Browse the repository at this point in the history
DM-38552: (hotfix) Protect test against special characters in parent directories
  • Loading branch information
timj committed Apr 6, 2023
2 parents 6c3fd44 + cbcce02 commit 94ae226
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def testResourcePath(self):

for uriInfo in uriStrings:
uri = ResourcePath(uriInfo[0], root=testRoot, forceAbsolute=uriInfo[1], forceDirectory=uriInfo[2])
with self.subTest(uri=uriInfo[0]):
with self.subTest(in_uri=uriInfo[0], out_uri=uri):
self.assertEqual(uri.scheme, uriInfo[3], "test scheme")
self.assertEqual(uri.netloc, uriInfo[4], "test netloc")
self.assertEqual(uri.path, uriInfo[5], "test path")
Expand All @@ -115,10 +115,12 @@ def testResourcePath(self):

for uriInfo in uriStrings:
uri = ResourcePath(uriInfo[0], forceAbsolute=uriInfo[1], forceDirectory=uriInfo[2])
with self.subTest(uri=uriInfo[0]):
with self.subTest(in_uri=uriInfo[0], out_uri=uri):
self.assertEqual(uri.scheme, uriInfo[3], "test scheme")
self.assertEqual(uri.netloc, uriInfo[4], "test netloc")
self.assertEqual(uri.path, uriInfo[5], "test path")
# Use ospath here to ensure that we have unquoted any
# special characters in the parent directories.
self.assertEqual(uri.ospath, uriInfo[5], "test path")

# File replacement
uriStrings = (
Expand All @@ -131,7 +133,7 @@ def testResourcePath(self):

for uriInfo in uriStrings:
uri = ResourcePath(uriInfo[0], forceAbsolute=False).updatedFile(uriInfo[1])
with self.subTest(uri=uriInfo[0]):
with self.subTest(in_uri=uriInfo[0], out_uri=uri):
self.assertEqual(uri.path, uriInfo[2])

# Check that schemeless can become file scheme.
Expand Down

0 comments on commit 94ae226

Please sign in to comment.