Commit 04a69a18 authored by Iustin Pop's avatar Iustin Pop
Browse files

ListVisibleFiles: require normalized path names

This patch changes ListVisibleFiles to raise ProgrammerError if it's
passed a non-absolute/non-normalized path name, and adds unittests for
this behaviour.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarMichael Hanselmann <>
parent 0411c011
......@@ -1221,8 +1221,12 @@ def ListVisibleFiles(path):
@param path: the directory to enumerate
@rtype: list
@return: the list of all files not starting with a dot
@raise ProgrammerError: if L{path} is not an absolue and normalized path
if not IsNormAbsPath(path):
raise errors.ProgrammerError("Path passed to ListVisibleFiles is not"
" absolute/normalized: '%s'" % path)
files = [i for i in os.listdir(path) if not i.startswith(".")]
return files
......@@ -897,6 +897,13 @@ class TestListVisibleFiles(unittest.TestCase):
expected = ["a", "b"]
self._test(files, expected)
def testNonAbsolutePath(self):
self.failUnlessRaises(errors.ProgrammerError, ListVisibleFiles, "abc")
def testNonNormalizedPath(self):
self.failUnlessRaises(errors.ProgrammerError, ListVisibleFiles,
class TestNewUUID(unittest.TestCase):
"""Test case for NewUUID"""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment