Exemplo n.º 1
0
 def setUp(self):
     self.tmpfile = tempfile.NamedTemporaryFile(delete=False)
     self.filename = self.tmpfile.name
     # on Windows the file can not be open second time, which
     # what FileLock does
     self.tmpfile.close()
     self.lock = locks.FileLock(self.filename)
Exemplo n.º 2
0
 def test_acquire_flock_error(self):
     filename = tempfile.NamedTemporaryFile()
     with locks.FileLock(filename.name):
         lock = locks.FileLock(filename.name)
         self.assertRaises(interfaces.AcquireError, lock.acquire)
Exemplo n.º 3
0
 def test_enter_contex_manager(self):
     with locks.FileLock(self.filename) as lock:
         self.assertEqual(lock.locked, True)
Exemplo n.º 4
0
 def test_exit_contex_manager(self):
     context_manager = locks.FileLock(self.filename)
     lock = context_manager.__enter__()
     lock.__exit__(None, None, None)
     self.assertEqual(lock.locked, False)
Exemplo n.º 5
0
 def setUp(self):
     self.filename = tempfile.NamedTemporaryFile()
     self.lock = locks.FileLock(self.filename.name)