util: Strip file:// from local urls
Make sure that the function returns a path even for local files specified by file:// urls. JIRA: RHELCMP-5340 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
c27bfe0c59
commit
7fe32ae758
@ -1046,6 +1046,8 @@ def as_local_file(url):
|
||||
yield local_filename
|
||||
finally:
|
||||
os.remove(local_filename)
|
||||
elif url.startswith("file://"):
|
||||
yield url[7:]
|
||||
else:
|
||||
# Not a remote url, return unchanged.
|
||||
yield url
|
||||
|
@ -1060,3 +1060,8 @@ class TestAsLocalFile(PungiTestCase):
|
||||
self.assertEqual(fn, self.filename)
|
||||
self.assertTrue(os.path.exists(self.filename))
|
||||
self.assertFalse(os.path.exists(self.filename))
|
||||
|
||||
def test_file_url(self, urlretrieve):
|
||||
with util.as_local_file("file:///tmp/foo") as fn:
|
||||
self.assertEqual(fn, "/tmp/foo")
|
||||
self.assertEqual(urlretrieve.call_args_list, [])
|
||||
|
Loading…
Reference in New Issue
Block a user