コード例 #1
0
 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))
コード例 #2
0
 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))
コード例 #3
0
 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)
コード例 #4
0
 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)