##// END OF EJS Templates
test-lock.py: move temp dir generation to testcase...
Siddharth Agarwal -
r26382:b673e89a default
parent child Browse files
Show More
@@ -13,13 +13,12 b' from mercurial import ('
13 testlockname = 'testlock'
13 testlockname = 'testlock'
14
14
15 class teststate(object):
15 class teststate(object):
16 def __init__(self, testcase):
16 def __init__(self, testcase, dir):
17 self._testcase = testcase
17 self._testcase = testcase
18 self._acquirecalled = False
18 self._acquirecalled = False
19 self._releasecalled = False
19 self._releasecalled = False
20 self._postreleasecalled = False
20 self._postreleasecalled = False
21 d = tempfile.mkdtemp(dir=os.getcwd())
21 self.vfs = scmutil.vfs(dir, audit=False)
22 self.vfs = scmutil.vfs(d, audit=False)
23
22
24 def makelock(self, *args, **kwargs):
23 def makelock(self, *args, **kwargs):
25 l = lock.lock(self.vfs, testlockname, releasefn=self.releasefn,
24 l = lock.lock(self.vfs, testlockname, releasefn=self.releasefn,
@@ -86,7 +85,7 b' class teststate(object):'
86
85
87 class testlock(unittest.TestCase):
86 class testlock(unittest.TestCase):
88 def testlock(self):
87 def testlock(self):
89 state = teststate(self)
88 state = teststate(self, tempfile.mkdtemp(dir=os.getcwd()))
90 lock = state.makelock()
89 lock = state.makelock()
91 state.assertacquirecalled(True)
90 state.assertacquirecalled(True)
92 lock.release()
91 lock.release()
@@ -95,7 +94,7 b' class testlock(unittest.TestCase):'
95 state.assertlockexists(False)
94 state.assertlockexists(False)
96
95
97 def testrecursivelock(self):
96 def testrecursivelock(self):
98 state = teststate(self)
97 state = teststate(self, tempfile.mkdtemp(dir=os.getcwd()))
99 lock = state.makelock()
98 lock = state.makelock()
100 state.assertacquirecalled(True)
99 state.assertacquirecalled(True)
101
100
@@ -115,7 +114,7 b' class testlock(unittest.TestCase):'
115 state.assertlockexists(False)
114 state.assertlockexists(False)
116
115
117 def testlockfork(self):
116 def testlockfork(self):
118 state = teststate(self)
117 state = teststate(self, tempfile.mkdtemp(dir=os.getcwd()))
119 lock = state.makelock()
118 lock = state.makelock()
120 state.assertacquirecalled(True)
119 state.assertacquirecalled(True)
121 lock.lock()
120 lock.lock()
General Comments 0
You need to be logged in to leave comments. Login now