# HG changeset patch # User Gregory Szorc # Date 2019-01-30 21:30:01 # Node ID 90b3898cf0db0346f84723f4d173bd3833968ceb # Parent 6309ce86fa825bba7fbcd97a90f4ea02fcf626a9 tests: various Python 3 ports for test-remotefilelog-datapack.py Use bytes I/O. Use byteschr(). Convert temporary path to bytes. Differential Revision: https://phab.mercurial-scm.org/D5758 diff --git a/tests/test-remotefilelog-datapack.py b/tests/test-remotefilelog-datapack.py --- a/tests/test-remotefilelog-datapack.py +++ b/tests/test-remotefilelog-datapack.py @@ -40,7 +40,7 @@ class datapacktestsbase(object): shutil.rmtree(d) def makeTempDir(self): - tempdir = tempfile.mkdtemp() + tempdir = pycompat.bytestr(tempfile.mkdtemp()) self.tempdirs.append(tempdir) return tempdir @@ -48,7 +48,8 @@ class datapacktestsbase(object): return hashlib.sha1(content).digest() def getFakeHash(self): - return ''.join(chr(random.randint(0, 255)) for _ in range(20)) + return b''.join(pycompat.bytechr(random.randint(0, 255)) + for _ in range(20)) def createPack(self, revisions=None, packdir=None): if revisions is None: @@ -221,11 +222,11 @@ class datapacktestsbase(object): def testBadVersionThrows(self): pack = self.createPack() path = pack.path + b'.datapack' - with open(path) as f: + with open(path, 'rb') as f: raw = f.read() raw = struct.pack('!B', 255) + raw[1:] os.chmod(path, os.stat(path).st_mode | stat.S_IWRITE) - with open(path, 'w+') as f: + with open(path, 'wb+') as f: f.write(raw) try: