Mercurial > piecrust2
comparison tests/mockutil.py @ 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 | 2a5996e0d3ec |
children | 89cc71928f6a |
comparison
equal
deleted
inserted
replaced
334:b034f6f15e22 | 335:8511137d1b62 |
---|---|
247 | 247 |
248 self._createMock('codecs.open', codecs.open, self._codecsOpen) | 248 self._createMock('codecs.open', codecs.open, self._codecsOpen) |
249 self._createMock('os.listdir', os.listdir, self._listdir) | 249 self._createMock('os.listdir', os.listdir, self._listdir) |
250 self._createMock('os.makedirs', os.makedirs, self._makedirs) | 250 self._createMock('os.makedirs', os.makedirs, self._makedirs) |
251 self._createMock('os.remove', os.remove, self._remove) | 251 self._createMock('os.remove', os.remove, self._remove) |
252 self._createMock('os.rename', os.rename, self._rename) | |
252 self._createMock('os.path.exists', os.path.exists, self._exists) | 253 self._createMock('os.path.exists', os.path.exists, self._exists) |
253 self._createMock('os.path.isdir', os.path.isdir, self._isdir) | 254 self._createMock('os.path.isdir', os.path.isdir, self._isdir) |
254 self._createMock('os.path.isfile', os.path.isfile, self._isfile) | 255 self._createMock('os.path.isfile', os.path.isfile, self._isfile) |
255 self._createMock('os.path.islink', os.path.islink, self._islink) | 256 self._createMock('os.path.islink', os.path.islink, self._islink) |
256 self._createMock('os.path.getmtime', os.path.getmtime, self._getmtime) | 257 self._createMock('os.path.getmtime', os.path.getmtime, self._getmtime) |
369 src_text = e.contents | 370 src_text = e.contents |
370 if not dst.replace('\\', '/').startswith('/' + self.root): | 371 if not dst.replace('\\', '/').startswith('/' + self.root): |
371 raise Exception("Shouldn't copy to: %s" % dst) | 372 raise Exception("Shouldn't copy to: %s" % dst) |
372 self._fs._createFile(dst, src_text) | 373 self._fs._createFile(dst, src_text) |
373 | 374 |
375 def _rename(self, src, dst): | |
376 src = os.path.normpath(src) | |
377 if src.startswith(resources_path) or dst.startswith(resources_path): | |
378 raise Exception("Shouldn't rename files in the resources path.") | |
379 self._copyfile(src, dst) | |
380 self._remove(src) | |
381 | |
374 def _rmtree(self, path): | 382 def _rmtree(self, path): |
375 if not path.replace('\\', '/').startswith('/' + self.root): | 383 if not path.replace('\\', '/').startswith('/' + self.root): |
376 raise Exception("Shouldn't delete trees from: %s" % path) | 384 raise Exception("Shouldn't delete trees from: %s" % path) |
377 e = self._fs._getEntry(os.path.dirname(path)) | 385 e = self._fs._getEntry(os.path.dirname(path)) |
378 del e[os.path.basename(path)] | 386 del e[os.path.basename(path)] |