def testLockException(self, mock_flock): error = IOError('Test Error') mock_flock.side_effect = error try: file_utils.Lock(self.fd, self.path, False) except IOError as e: self.assertTrue(self.path in str(e)) self.assertTrue('Test Error' in str(e))
def testLockTakenException(self, mock_flock): error = IOError('Test Error') error.errno = file_utils.errno.EWOULDBLOCK mock_flock.side_effect = error try: file_utils.Lock(self.fd, self.path, False) except IOError as e: self.assertTrue(self.path in str(e))
def testLockBlocking(self, mock_flock): operation = file_utils.fcntl.LOCK_EX file_utils.Lock(self.fd, self.path, True) mock_flock.assert_called_once_with(self.fd, operation)
def testLock(self, mock_flock): operation = file_utils.fcntl.LOCK_EX | file_utils.fcntl.LOCK_NB file_utils.Lock(self.fd, self.path, False) mock_flock.assert_called_once_with(self.fd, operation)