Patchwork [2,of,7] test-lock.py: move temp dir generation to testcase

login
register
mail settings
Submitter Siddharth Agarwal
Date Sept. 25, 2015, 7 p.m.
Message ID <2b835a6b40b64223f477.1443207636@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10637/
State Accepted
Headers show

Comments

Siddharth Agarwal - Sept. 25, 2015, 7 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1443149554 25200
#      Thu Sep 24 19:52:34 2015 -0700
# Node ID 2b835a6b40b64223f4771c89e888fbd8837ecbf7
# Parent  2f8bf83ce463c84342897fbb904f07c68b7919d7
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.

Patch

diff --git a/tests/test-lock.py b/tests/test-lock.py
--- a/tests/test-lock.py
+++ b/tests/test-lock.py
@@ -13,13 +13,12 @@  from mercurial import (
 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 teststate(object):
 
 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 @@  class testlock(unittest.TestCase):
         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 @@  class testlock(unittest.TestCase):
         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()