summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-07-11 10:16:53 +1200
committerLars Wirzenius <liw@liw.fi>2010-07-11 10:16:53 +1200
commit014802c04252422d65ef23d36103c2e4d4c04fbc (patch)
treec1545bb805640fcba7f5d1452b1746bf65f9a2a8
parentdd578023cdd9535c21797caed3dc689017e47cd8 (diff)
downloadobnam-014802c04252422d65ef23d36103c2e4d4c04fbc.tar.gz
Add test for lstat raising OSError for nonexistent target.
-rw-r--r--obnamlib/plugins/sftp_plugin.py5
-rw-r--r--obnamlib/vfs.py3
2 files changed, 7 insertions, 1 deletions
diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py
index f7110942..df2c1243 100644
--- a/obnamlib/plugins/sftp_plugin.py
+++ b/obnamlib/plugins/sftp_plugin.py
@@ -182,7 +182,10 @@ class SftpFS(obnamlib.VirtualFileSystem):
self.sftp.rename(old, new)
def lstat(self, pathname):
- return self.sftp.lstat(pathname)
+ try:
+ return self.sftp.lstat(pathname)
+ except IOError, e:
+ raise OSError(e.errno, e.strerror, pathname)
def chown(self, pathname, uid, gid):
self.sftp.chown(pathname, uid, gid)
diff --git a/obnamlib/vfs.py b/obnamlib/vfs.py
index 070b0cff..6ecb161b 100644
--- a/obnamlib/vfs.py
+++ b/obnamlib/vfs.py
@@ -378,6 +378,9 @@ class VfsTests(object): # pragma: no cover
def test_lstat_returns_result(self):
self.assert_(self.fs.lstat('.'))
+ def test_lstat_raises_oserror_for_nonexistent_entry(self):
+ self.assertRaises(OSError, self.fs.lstat, 'notexists')
+
def test_chmod_sets_permissions_correctly(self):
self.fs.mkdir('foo')
self.fs.chmod('foo', 0777)