Ejemplo n.º 1
0
 def test_lock(self):
     """Basic locking test."""
     lock = FileLock(self.testfile)
     lock.acquire()
     self.assertTrue(lock.is_locked)
     self.assertTrue(lock.check_lock())
     lock.release()
     self.assertFalse(lock.is_locked)
     self.assertFalse(lock.check_lock())
Ejemplo n.º 2
0
 def test_context(self):
     """Test of context handling."""
     lock = FileLock(self.testfile)
     lock2 = FileLock(self.testfile, timeout=0)
     with lock:
         self.assertTrue(lock.is_locked)
         self.assertTrue(lock.check_lock())
         self.assertRaises(FileLockException, lock2.acquire)
     self.assertFalse(lock.is_locked)
     self.assertFalse(lock.check_lock())