From da1650ef882f7de4158118db71f7a2fdd196bc0a Mon Sep 17 00:00:00 2001 From: Alpha Date: Sat, 29 Aug 2015 23:47:43 -0400 Subject: Provide use_errno to all gfapi foreign function prototypes Updated tests to include OSError messages Added error reasons to LibgfapiException exceptions BUG 1196161: https://bugzilla.redhat.com/show_bug.cgi?id=1196161 Change-Id: Iddf40751696874ffcaa50cd9d5ecc06c4993baf2 Signed-off-by: Prashanth Pai --- test/functional/libgfapi-python-tests.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/functional/libgfapi-python-tests.py b/test/functional/libgfapi-python-tests.py index 87dbfe0..7eb4cd2 100644 --- a/test/functional/libgfapi-python-tests.py +++ b/test/functional/libgfapi-python-tests.py @@ -133,7 +133,13 @@ class FileOpsTest(unittest.TestCase): # invalid mode self.assertRaises(ValueError, self.vol.fopen, "file", 'x+') # file does not exist - self.assertRaises(OSError, self.vol.fopen, "file", 'r') + try: + self.vol.fopen("file", "r") + except OSError as err: + if err.errno != errno.ENOENT: + self.fail("Expecting ENOENT") + else: + self.fail("Expecting ENOENT") def test_fopen(self): # Default permission should be 0666 @@ -290,7 +296,13 @@ class FileOpsTest(unittest.TestCase): def test_rename(self): newpath = self.path + ".rename" self.vol.rename(self.path, newpath) - self.assertRaises(OSError, self.vol.lstat, self.path) + try: + self.vol.lstat(self.path) + except OSError as err: + if err.errno != errno.ENOENT: + self.fail("Expecting ENOENT") + else: + self.fail("Expecting ENOENT") def test_stat(self): sb = self.vol.stat(self.path) @@ -299,7 +311,13 @@ class FileOpsTest(unittest.TestCase): def test_unlink(self): self.vol.unlink(self.path) - self.assertRaises(OSError, self.vol.lstat, self.path) + try: + self.vol.lstat(self.path) + except OSError as err: + if err.errno != errno.ENOENT: + self.fail("Expecting ENOENT") + else: + self.fail("Expecting ENOENT") def test_setxattr(self): value = "hello world" -- cgit