# HG changeset patch # User Siddharth Agarwal # Date 1443149554 25200 # Node ID b673e89affc9d252d1e237cc95bd56c6a8be145f # Parent 94dc10834b79bf5666b8461e11a4d27a7e4d2f7e test-lock.py: move temp dir generation to testcase In upcoming patches we'll want to create multiple test state objects with a common test directory. diff -r 94dc10834b79 -r b673e89affc9 tests/test-lock.py --- a/tests/test-lock.py Thu Sep 24 17:33:13 2015 -0700 +++ b/tests/test-lock.py Thu Sep 24 19:52:34 2015 -0700 @@ -13,13 +13,12 @@ testlockname = 'testlock' class teststate(object): - def __init__(self, testcase): + def __init__(self, testcase, dir): self._testcase = testcase self._acquirecalled = False self._releasecalled = False self._postreleasecalled = False - d = tempfile.mkdtemp(dir=os.getcwd()) - self.vfs = scmutil.vfs(d, audit=False) + self.vfs = scmutil.vfs(dir, audit=False) def makelock(self, *args, **kwargs): l = lock.lock(self.vfs, testlockname, releasefn=self.releasefn, @@ -86,7 +85,7 @@ class testlock(unittest.TestCase): def testlock(self): - state = teststate(self) + state = teststate(self, tempfile.mkdtemp(dir=os.getcwd())) lock = state.makelock() state.assertacquirecalled(True) lock.release() @@ -95,7 +94,7 @@ state.assertlockexists(False) def testrecursivelock(self): - state = teststate(self) + state = teststate(self, tempfile.mkdtemp(dir=os.getcwd())) lock = state.makelock() state.assertacquirecalled(True) @@ -115,7 +114,7 @@ state.assertlockexists(False) def testlockfork(self): - state = teststate(self) + state = teststate(self, tempfile.mkdtemp(dir=os.getcwd())) lock = state.makelock() state.assertacquirecalled(True) lock.lock()