# HG changeset patch # User Siddharth Agarwal # Date 2015-09-25 03:22:59 # Node ID ad6e56d01c30df267bc9f3cbc4a778420367ba26 # Parent 0fceb34806e16e99722d1cdb5c08310e70a5e37d test-lock.py: add a lock wrapper that allows faking the PID This will be used in upcoming patches to create locks that appear as if they're being created by child processes. diff --git a/tests/test-lock.py b/tests/test-lock.py --- a/tests/test-lock.py +++ b/tests/test-lock.py @@ -12,6 +12,15 @@ from mercurial import ( testlockname = 'testlock' +class lockwrapper(lock.lock): + def __init__(self, pidoffset, *args, **kwargs): + # lock.lock.__init__() calls lock(), so the pidoffset assignment needs + # to be earlier + self._pidoffset = pidoffset + super(lockwrapper, self).__init__(*args, **kwargs) + def _getpid(self): + return os.getpid() + self._pidoffset + class teststate(object): def __init__(self, testcase, dir): self._testcase = testcase