Show More
@@ -40,7 +40,7 b' class datapacktestsbase(object):' | |||||
40 | shutil.rmtree(d) |
|
40 | shutil.rmtree(d) | |
41 |
|
41 | |||
42 | def makeTempDir(self): |
|
42 | def makeTempDir(self): | |
43 | tempdir = tempfile.mkdtemp() |
|
43 | tempdir = pycompat.bytestr(tempfile.mkdtemp()) | |
44 | self.tempdirs.append(tempdir) |
|
44 | self.tempdirs.append(tempdir) | |
45 | return tempdir |
|
45 | return tempdir | |
46 |
|
46 | |||
@@ -48,7 +48,8 b' class datapacktestsbase(object):' | |||||
48 | return hashlib.sha1(content).digest() |
|
48 | return hashlib.sha1(content).digest() | |
49 |
|
49 | |||
50 | def getFakeHash(self): |
|
50 | def getFakeHash(self): | |
51 |
return ''.join(chr(random.randint(0, 255)) |
|
51 | return b''.join(pycompat.bytechr(random.randint(0, 255)) | |
|
52 | for _ in range(20)) | |||
52 |
|
53 | |||
53 | def createPack(self, revisions=None, packdir=None): |
|
54 | def createPack(self, revisions=None, packdir=None): | |
54 | if revisions is None: |
|
55 | if revisions is None: | |
@@ -221,11 +222,11 b' class datapacktestsbase(object):' | |||||
221 | def testBadVersionThrows(self): |
|
222 | def testBadVersionThrows(self): | |
222 | pack = self.createPack() |
|
223 | pack = self.createPack() | |
223 | path = pack.path + b'.datapack' |
|
224 | path = pack.path + b'.datapack' | |
224 | with open(path) as f: |
|
225 | with open(path, 'rb') as f: | |
225 | raw = f.read() |
|
226 | raw = f.read() | |
226 | raw = struct.pack('!B', 255) + raw[1:] |
|
227 | raw = struct.pack('!B', 255) + raw[1:] | |
227 | os.chmod(path, os.stat(path).st_mode | stat.S_IWRITE) |
|
228 | os.chmod(path, os.stat(path).st_mode | stat.S_IWRITE) | |
228 | with open(path, 'w+') as f: |
|
229 | with open(path, 'wb+') as f: | |
229 | f.write(raw) |
|
230 | f.write(raw) | |
230 |
|
231 | |||
231 | try: |
|
232 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now