Skip to content

Commit 65aec2a

Browse files
committed
normalize paths on MS Windows
1 parent 854234d commit 65aec2a

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

tests/test_fetch.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from cwltool.main import main
1313
from cwltool.workflow import defaultMakeTool
1414
from cwltool.resolver import resolve_local
15+
from cwltool.utils import onWindows
1516

1617
if sys.version_info < (3, 4):
1718
from pathlib2 import Path
@@ -71,15 +72,25 @@ class ResolverTest(unittest.TestCase):
7172
def test_resolve_local(self):
7273
origpath = os.getcwd()
7374
os.chdir(os.path.join(get_data("")))
75+
def norm(uri):
76+
if onWindows():
77+
return uri.lower()
78+
else:
79+
return uri
7480
try:
7581
root = Path.cwd()
7682
rooturi = root.as_uri()
77-
self.assertEqual(rooturi+"/tests/echo.cwl", resolve_local(None, os.path.join("tests", "echo.cwl")))
78-
self.assertEqual(rooturi+"/tests/echo.cwl#main", resolve_local(None, os.path.join("tests", "echo.cwl")+"#main"))
79-
self.assertEqual(rooturi+"/tests/echo.cwl", resolve_local(None, str(root / "tests" / "echo.cwl")))
80-
# On Windows and Python 2.7, the left side of this test returns
81-
# file:///C:/ (uppercase drive letter) and the right side returns
82-
# file:///c:/ (lowercase drive letter) so force a lowercase comparison.
83-
self.assertEqual((rooturi+"/tests/echo.cwl#main").lower(), resolve_local(None, str(root / "tests" / "echo.cwl")+"#main").lower())
83+
self.assertEqual(norm(rooturi+"/tests/echo.cwl"),
84+
norm(resolve_local(None, os.path.join("tests",
85+
"echo.cwl"))))
86+
self.assertEqual(norm(rooturi+"/tests/echo.cwl#main"),
87+
norm(resolve_local(None, os.path.join("tests",
88+
"echo.cwl")+"#main")))
89+
self.assertEqual(norm(rooturi+"/tests/echo.cwl"),
90+
norm(resolve_local(None, str(root / "tests" /
91+
"echo.cwl"))))
92+
self.assertEqual(norm(rooturi+"/tests/echo.cwl#main"),
93+
norm(resolve_local(None, str(root / "tests" /
94+
"echo.cwl")+"#main")))
8495
finally:
8596
os.chdir(origpath)

0 commit comments

Comments
 (0)