--- a/tests/test-lock.py Thu Sep 17 22:34:36 2020 -0700
+++ b/tests/test-lock.py Fri Sep 18 08:27:43 2020 -0700
@@ -169,121 +169,6 @@
state.assertpostreleasecalled(True)
state.assertlockexists(False)
- def testinheritlock(self):
- d = tempfile.mkdtemp(dir=encoding.getcwd())
- parentstate = teststate(self, d)
- parentlock = parentstate.makelock()
- parentstate.assertacquirecalled(True)
-
- # set up lock inheritance
- with parentlock.inherit() as lockname:
- parentstate.assertreleasecalled(True)
- parentstate.assertpostreleasecalled(False)
- parentstate.assertlockexists(True)
-
- childstate = teststate(self, d, pidoffset=1)
- childlock = childstate.makelock(parentlock=lockname)
- childstate.assertacquirecalled(True)
-
- childlock.release()
- childstate.assertreleasecalled(True)
- childstate.assertpostreleasecalled(False)
- childstate.assertlockexists(True)
-
- parentstate.resetacquirefn()
-
- parentstate.assertacquirecalled(True)
-
- parentlock.release()
- parentstate.assertreleasecalled(True)
- parentstate.assertpostreleasecalled(True)
- parentstate.assertlockexists(False)
-
- def testmultilock(self):
- d = tempfile.mkdtemp(dir=encoding.getcwd())
- state0 = teststate(self, d)
- lock0 = state0.makelock()
- state0.assertacquirecalled(True)
-
- with lock0.inherit() as lock0name:
- state0.assertreleasecalled(True)
- state0.assertpostreleasecalled(False)
- state0.assertlockexists(True)
-
- state1 = teststate(self, d, pidoffset=1)
- lock1 = state1.makelock(parentlock=lock0name)
- state1.assertacquirecalled(True)
-
- # from within lock1, acquire another lock
- with lock1.inherit() as lock1name:
- # since the file on disk is lock0's this should have the same
- # name
- self.assertEqual(lock0name, lock1name)
-
- state2 = teststate(self, d, pidoffset=2)
- lock2 = state2.makelock(parentlock=lock1name)
- state2.assertacquirecalled(True)
-
- lock2.release()
- state2.assertreleasecalled(True)
- state2.assertpostreleasecalled(False)
- state2.assertlockexists(True)
-
- state1.resetacquirefn()
-
- state1.assertacquirecalled(True)
-
- lock1.release()
- state1.assertreleasecalled(True)
- state1.assertpostreleasecalled(False)
- state1.assertlockexists(True)
-
- lock0.release()
-
- def testinheritlockfork(self):
- d = tempfile.mkdtemp(dir=encoding.getcwd())
- parentstate = teststate(self, d)
- parentlock = parentstate.makelock()
- parentstate.assertacquirecalled(True)
-
- # set up lock inheritance
- with parentlock.inherit() as lockname:
- childstate = teststate(self, d, pidoffset=1)
- childlock = childstate.makelock(parentlock=lockname)
- childstate.assertacquirecalled(True)
-
- # fork the child lock
- forkchildlock = copy.copy(childlock)
- forkchildlock._pidoffset += 1
- forkchildlock.release()
- childstate.assertreleasecalled(False)
- childstate.assertpostreleasecalled(False)
- childstate.assertlockexists(True)
-
- # release the child lock
- childlock.release()
- childstate.assertreleasecalled(True)
- childstate.assertpostreleasecalled(False)
- childstate.assertlockexists(True)
-
- parentlock.release()
-
- def testinheritcheck(self):
- d = tempfile.mkdtemp(dir=encoding.getcwd())
- state = teststate(self, d)
-
- def check():
- raise error.LockInheritanceContractViolation('check failed')
-
- lock = state.makelock(inheritchecker=check)
- state.assertacquirecalled(True)
-
- with self.assertRaises(error.LockInheritanceContractViolation):
- with lock.inherit():
- pass
-
- lock.release()
-
def testfrequentlockunlock(self):
"""This tests whether lock acquisition fails as expected, even if
(1) lock can't be acquired (makelock fails by EEXIST), and