summaryrefslogtreecommitdiffhomepage
path: root/tests/stub_sftp.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stub_sftp.py')
-rw-r--r--tests/stub_sftp.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/stub_sftp.py b/tests/stub_sftp.py
index 06ceb419..100076d6 100644
--- a/tests/stub_sftp.py
+++ b/tests/stub_sftp.py
@@ -30,6 +30,7 @@ from paramiko import (
SFTPAttributes,
SFTPHandle,
SFTP_OK,
+ SFTP_FAILURE,
AUTH_SUCCESSFUL,
OPEN_SUCCEEDED,
)
@@ -150,6 +151,17 @@ class StubSFTPServer(SFTPServerInterface):
def rename(self, oldpath, newpath):
oldpath = self._realpath(oldpath)
newpath = self._realpath(newpath)
+ if os.path.exists(newpath):
+ return SFTP_FAILURE
+ try:
+ os.rename(oldpath, newpath)
+ except OSError as e:
+ return SFTPServer.convert_errno(e.errno)
+ return SFTP_OK
+
+ def posix_rename(self, oldpath, newpath):
+ oldpath = self._realpath(oldpath)
+ newpath = self._realpath(newpath)
try:
os.rename(oldpath, newpath)
except OSError as e: