tests/test-lock.py
changeset 26498 e8564e04382d
parent 26474 431094a3b21f
child 26499 e72b62b154b0
--- a/tests/test-lock.py	Tue Oct 06 15:55:50 2015 -0700
+++ b/tests/test-lock.py	Tue Oct 06 13:13:31 2015 -0700
@@ -8,6 +8,7 @@
 import unittest
 
 from mercurial import (
+    error,
     lock,
     scmutil,
 )
@@ -250,5 +251,21 @@
 
         parentlock.release()
 
+    def testinheritcheck(self):
+        d = tempfile.mkdtemp(dir=os.getcwd())
+        state = teststate(self, d)
+        def check():
+            raise error.LockInheritanceContractViolation('check failed')
+        lock = state.makelock(inheritchecker=check)
+        state.assertacquirecalled(True)
+
+        def tryinherit():
+            with lock.inherit() as lockname:
+                pass
+
+        self.assertRaises(error.LockInheritanceContractViolation, tryinherit)
+
+        lock.release()
+
 if __name__ == '__main__':
     silenttestrunner.main(__name__)