Exemplo n.º 1
0
    def testFileLockAcquireException(self):
        # Expects an exception when file is not opened for read or write

        self._tempFileID.close()
        with self.assertRaises(file_lock.FileLockAcquireException):
            with file_lock._FileLock(self._tempFileID, fcntl.LOCK_SH) as f_err:
                self.assertIn("FileLock acquire failed on", f_err.exception.args[0])

        with self.assertRaises(file_lock.FileLockAcquireException):
            with file_lock._FileLock([], fcntl.LOCK_SH) as f_err:
                self.assertIn("FileLock acquire failed on", f_err.exception.args[0])
Exemplo n.º 2
0
    def testFileLockAcquireException(self):
        # Expects an exception when file is not opened for read or write

        self._tempFileID.close()
        with self.assertRaises(file_lock.FileLockAcquireException):
            with file_lock._FileLock(self._tempFileID, fcntl.LOCK_SH) as f_err:
                self.assertIn("FileLock acquire failed on",
                              f_err.exception.args[0])

        with self.assertRaises(file_lock.FileLockAcquireException):
            with file_lock._FileLock([], fcntl.LOCK_SH) as f_err:
                self.assertIn("FileLock acquire failed on",
                              f_err.exception.args[0])
Exemplo n.º 3
0
 def testValidLockOperation(self):
     # lockOperation must be one of {LOCK_UN, LOCK_SH, LOCK_EX}
     with self.assertRaises(AttributeError):
         file_lock._FileLock(self._tempFileID, fcntl.LOCK_S)
Exemplo n.º 4
0
 def testContextMgrWithGoodFile(self):
     with file_lock._FileLock(self._tempFileID, fcntl.LOCK_SH) as flock:
         self.assertEqual(type(flock), file_lock._FileLock)
Exemplo n.º 5
0
 def testValidLockOperation(self):
     # lockOperation must be one of {LOCK_UN, LOCK_SH, LOCK_EX}
     with self.assertRaises(AttributeError):
         file_lock._FileLock(self._tempFileID, fcntl.LOCK_S)
Exemplo n.º 6
0
 def testContextMgrWithGoodFile(self):
     with file_lock._FileLock(self._tempFileID, fcntl.LOCK_SH) as flock:
         self.assertEqual(type(flock), file_lock._FileLock)