diff --git a/pungi/util.py b/pungi/util.py index cf1ec8ee..c5717bde 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -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 diff --git a/tests/test_util.py b/tests/test_util.py index 29d85cfa..181c91d8 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -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, [])