def testUnlockTakenException(self, mock_flock): error = IOError('Test Error') error.errno = file_utils.errno.EWOULDBLOCK mock_flock.side_effect = error try: file_utils.Unlock(self.fd, self.path) except IOError as e: self.assertTrue(self.path in str(e))
def testUnlockException(self, mock_flock): error = IOError('Test Error') mock_flock.side_effect = error try: file_utils.Unlock(self.fd, self.path) except IOError as e: self.assertTrue(self.path in str(e)) self.assertTrue('Test Error' in str(e))
def testUnlock(self, mock_flock): operation = file_utils.fcntl.LOCK_UN | file_utils.fcntl.LOCK_NB file_utils.Unlock(self.fd, self.path) mock_flock.assert_called_once_with(self.fd, operation)