py3: byteify test-lock.py
authorMatt Harbison <matt_harbison@yahoo.com>
Mon, 01 Oct 2018 21:54:00 -0400
changeset 39948 5ee3146c1b20
parent 39947 a063b84ce064
child 39949 e1f97179a3f5
py3: byteify test-lock.py There's still a stacktrace about not being able to serialize _io.TextIOWrapper.
tests/test-lock.py
--- a/tests/test-lock.py	Mon Oct 01 21:48:45 2018 -0400
+++ b/tests/test-lock.py	Mon Oct 01 21:54:00 2018 -0400
@@ -2,19 +2,19 @@
 
 import copy
 import errno
-import os
 import silenttestrunner
 import tempfile
 import types
 import unittest
 
 from mercurial import (
+    encoding,
     error,
     lock,
     vfs as vfsmod,
 )
 
-testlockname = 'testlock'
+testlockname = b'testlock'
 
 # work around http://bugs.python.org/issue1515
 if types.MethodType not in copy._deepcopy_dispatch:
@@ -106,7 +106,7 @@
 
 class testlock(unittest.TestCase):
     def testlock(self):
-        state = teststate(self, tempfile.mkdtemp(dir=os.getcwd()))
+        state = teststate(self, tempfile.mkdtemp(dir=encoding.getcwd()))
         lock = state.makelock()
         state.assertacquirecalled(True)
         lock.release()
@@ -115,7 +115,7 @@
         state.assertlockexists(False)
 
     def testrecursivelock(self):
-        state = teststate(self, tempfile.mkdtemp(dir=os.getcwd()))
+        state = teststate(self, tempfile.mkdtemp(dir=encoding.getcwd()))
         lock = state.makelock()
         state.assertacquirecalled(True)
 
@@ -135,7 +135,7 @@
         state.assertlockexists(False)
 
     def testlockfork(self):
-        state = teststate(self, tempfile.mkdtemp(dir=os.getcwd()))
+        state = teststate(self, tempfile.mkdtemp(dir=encoding.getcwd()))
         lock = state.makelock()
         state.assertacquirecalled(True)
 
@@ -154,7 +154,7 @@
         state.assertlockexists(False)
 
     def testinheritlock(self):
-        d = tempfile.mkdtemp(dir=os.getcwd())
+        d = tempfile.mkdtemp(dir=encoding.getcwd())
         parentstate = teststate(self, d)
         parentlock = parentstate.makelock()
         parentstate.assertacquirecalled(True)
@@ -184,7 +184,7 @@
         parentstate.assertlockexists(False)
 
     def testmultilock(self):
-        d = tempfile.mkdtemp(dir=os.getcwd())
+        d = tempfile.mkdtemp(dir=encoding.getcwd())
         state0 = teststate(self, d)
         lock0 = state0.makelock()
         state0.assertacquirecalled(True)
@@ -225,7 +225,7 @@
         lock0.release()
 
     def testinheritlockfork(self):
-        d = tempfile.mkdtemp(dir=os.getcwd())
+        d = tempfile.mkdtemp(dir=encoding.getcwd())
         parentstate = teststate(self, d)
         parentlock = parentstate.makelock()
         parentstate.assertacquirecalled(True)
@@ -253,7 +253,7 @@
         parentlock.release()
 
     def testinheritcheck(self):
-        d = tempfile.mkdtemp(dir=os.getcwd())
+        d = tempfile.mkdtemp(dir=encoding.getcwd())
         state = teststate(self, d)
         def check():
             raise error.LockInheritanceContractViolation('check failed')
@@ -273,7 +273,7 @@
         retrying 5 times.
         """
 
-        d = tempfile.mkdtemp(dir=os.getcwd())
+        d = tempfile.mkdtemp(dir=encoding.getcwd())
         state = teststate(self, d)
 
         def emulatefrequentlock(*args):