def test_enter_contex_manager(self): with locks.DirectoryLock(self.path) as lock: self.assertEqual(lock.locked, True) self.assertEqual( os.path.isfile(lock.filename), True, )
def test_exit_contex_manager(self): context_manager = locks.DirectoryLock(self.path) lock = context_manager.__enter__() lock.__exit__(None, None, None) self.assertEqual(lock.locked, False) self.assertEqual( os.path.isfile(lock.filename), False, )
def setUp(self): self.path = tempfile.mkdtemp() self.lock = locks.DirectoryLock(self.path)