# HG changeset patch # User Ludovic Chabant # Date 1429311928 25200 # Node ID c484e1ec9150e8ee0136da9dc1c4aedfcfb004d6 # Parent f43e911cecac766ab863b8135615f4bd56c3c409 tests: Add more utility functions to the mock file-system. diff -r f43e911cecac -r c484e1ec9150 tests/mockutil.py --- a/tests/mockutil.py Wed Apr 15 16:43:27 2015 -0700 +++ b/tests/mockutil.py Fri Apr 17 16:05:28 2015 -0700 @@ -165,12 +165,22 @@ root = self._getEntry(self.path(path)) if root is None: raise Exception("No such path: %s" % path) + if not isinstance(root, dict): + raise Exception("Path is not a directory: %s" % path) res = {} for k, v in root.items(): self._getStructureRecursive(v, res, k) return res + def getFileEntry(self, path): + entry = self._getEntry(self.path(path)) + if entry is None: + raise Exception("No such file: %s" % path) + if not isinstance(entry, _MockFsEntry): + raise Exception("Path is not a file: %s" % path) + return entry.contents + def _getStructureRecursive(self, src, target, name): if isinstance(src, _MockFsEntry): target[name] = src.contents