Mercurial > hg-stable
changeset 26384:ad6e56d01c30
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.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Thu, 24 Sep 2015 20:22:59 -0700 |
parents | 0fceb34806e1 |
children | fb1a424e8bff |
files | tests/test-lock.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-lock.py Thu Sep 24 21:26:37 2015 -0700 +++ b/tests/test-lock.py Thu Sep 24 20:22:59 2015 -0700 @@ -12,6 +12,15 @@ 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