Mercurial > hg
changeset 41473:90b3898cf0db
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
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 30 Jan 2019 13:30:01 -0800 |
parents | 6309ce86fa82 |
children | e971952db109 |
files | tests/test-remotefilelog-datapack.py |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-remotefilelog-datapack.py Wed Jan 30 13:22:42 2019 -0800 +++ b/tests/test-remotefilelog-datapack.py Wed Jan 30 13:30:01 2019 -0800 @@ -40,7 +40,7 @@ shutil.rmtree(d) def makeTempDir(self): - tempdir = tempfile.mkdtemp() + tempdir = pycompat.bytestr(tempfile.mkdtemp()) self.tempdirs.append(tempdir) return tempdir @@ -48,7 +48,8 @@ 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 @@ 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: