Some pathutils fixes (#589)

* Fix pathutil tests

* Handle IndexError in pathutils
This commit is contained in:
Karthik Nadig 2018-07-06 13:08:34 -07:00 committed by GitHub
parent 6b20c67794
commit 0be3795eb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View file

@ -54,9 +54,11 @@ class PathUnNormcase(object):
else:
test_name = [sep + dirs[0]]
for d in dirs[1:]:
test_name += ["{}[{}]".format(d[: - 1], d[-1])]
path = glob(sep.join(test_name))[0]
res = glob(sep.join((path, filename)))
test_name += ["{}[{}]".format(d[:-1], d[-1])]
path = glob(sep.join(test_name))
if not path:
return name
res = glob(sep.join((path[0], filename)))
if not res:
return name
return res[0]

View file

@ -61,9 +61,12 @@ class PathUtilTests(unittest.TestCase):
"Windows OS specific test")
def test_path_names_uppercase_disabled(self):
tool = PathUnNormcase()
result = tool.un_normcase(FILENAME.upper())
expected = FILENAME.upper()
result = tool.un_normcase(expected)
self.assertEqual(result, FILENAME)
# Since path tool is disabled we should get the same
# path back
self.assertEqual(result, expected)
@unittest.skipIf(platform.system() != 'Windows',
"Windows OS specific test")
@ -78,9 +81,12 @@ class PathUtilTests(unittest.TestCase):
"Windows OS specific test")
def test_path_names_lowercase_disabled(self):
tool = PathUnNormcase()
result = tool.un_normcase(FILENAME.lower())
expected = FILENAME.lower()
result = tool.un_normcase(expected)
self.assertEqual(result, FILENAME)
# Since path tool is disabled we should get the same
# path back
self.assertEqual(result, expected)
@unittest.skipIf(platform.system() != 'Windows',
"Windows OS specific test")