diff --git a/taskflow/persistence/backends/impl_memory.py b/taskflow/persistence/backends/impl_memory.py index e614247d..960ebe0c 100644 --- a/taskflow/persistence/backends/impl_memory.py +++ b/taskflow/persistence/backends/impl_memory.py @@ -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" diff --git a/taskflow/tests/unit/persistence/test_memory_persistence.py b/taskflow/tests/unit/persistence/test_memory_persistence.py index 2b3599e4..24f76aa3 100644 --- a/taskflow/tests/unit/persistence/test_memory_persistence.py +++ b/taskflow/tests/unit/persistence/test_memory_persistence.py @@ -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, '/')