changeset 335:8511137d1b62

tests: Add `os.rename` to the mocked functions.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 03 Apr 2015 11:20:30 -0700
parents b034f6f15e22
children aa6b7ff6a193
files tests/mockutil.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/mockutil.py	Fri Apr 03 10:59:50 2015 -0700
+++ b/tests/mockutil.py	Fri Apr 03 11:20:30 2015 -0700
@@ -249,6 +249,7 @@
         self._createMock('os.listdir', os.listdir, self._listdir)
         self._createMock('os.makedirs', os.makedirs, self._makedirs)
         self._createMock('os.remove', os.remove, self._remove)
+        self._createMock('os.rename', os.rename, self._rename)
         self._createMock('os.path.exists', os.path.exists, self._exists)
         self._createMock('os.path.isdir', os.path.isdir, self._isdir)
         self._createMock('os.path.isfile', os.path.isfile, self._isfile)
@@ -371,6 +372,13 @@
             raise Exception("Shouldn't copy to: %s" % dst)
         self._fs._createFile(dst, src_text)
 
+    def _rename(self, src, dst):
+        src = os.path.normpath(src)
+        if src.startswith(resources_path) or dst.startswith(resources_path):
+            raise Exception("Shouldn't rename files in the resources path.")
+        self._copyfile(src, dst)
+        self._remove(src)
+
     def _rmtree(self, path):
         if not path.replace('\\', '/').startswith('/' + self.root):
             raise Exception("Shouldn't delete trees from: %s" % path)