Merge "Ensure empty paths raise a value error"
This commit is contained in:
@@ -75,6 +75,9 @@ class FakeFilesystem(object):
|
||||
@classmethod
|
||||
def normpath(cls, path):
|
||||
"""Return a normalized absolutized version of the pathname path."""
|
||||
if not path:
|
||||
raise ValueError("This filesystem can only normalize paths"
|
||||
" that are not empty")
|
||||
if not path.startswith(cls.root_path):
|
||||
raise ValueError("This filesystem can only normalize"
|
||||
" paths that start with %s: '%s' is not"
|
||||
|
||||
@@ -128,6 +128,12 @@ class MemoryFilesystemTest(test.TestCase):
|
||||
fs = impl_memory.FakeFilesystem()
|
||||
self.assertRaises(exc.NotFound, self._get_item_path, fs, '/c')
|
||||
|
||||
def test_bad_norms(self):
|
||||
fs = impl_memory.FakeFilesystem()
|
||||
self.assertRaises(ValueError, fs.normpath, '')
|
||||
self.assertRaises(ValueError, fs.normpath, 'abc/c')
|
||||
self.assertRaises(ValueError, fs.normpath, '../c')
|
||||
|
||||
def test_del_root_not_allowed(self):
|
||||
fs = impl_memory.FakeFilesystem()
|
||||
self.assertRaises(ValueError, self._del_item_path, fs, '/')
|
||||
|
||||
Reference in New Issue
Block a user