Show More
@@ -35,7 +35,8 b' def testbasicreadwrite():' | |||
|
35 | 35 | ensure(rm.rev2hsh(i) is None) |
|
36 | 36 | ensure(rm.hsh2rev(b'\0' * 20) is None) |
|
37 | 37 | |
|
38 | paths = ['', 'a', None, 'b', 'b', 'c', 'c', None, 'a', 'b', 'a', 'a'] | |
|
38 | paths = [ | |
|
39 | b'', b'a', None, b'b', b'b', b'c', b'c', None, b'a', b'b', b'a', b'a'] | |
|
39 | 40 | for i in xrange(1, 5): |
|
40 | 41 | ensure(rm.append(genhsh(i), sidebranch=(i & 1), path=paths[i]) == i) |
|
41 | 42 | |
@@ -88,7 +89,7 b' def testcorruptformat():' | |||
|
88 | 89 | path = gettemppath() |
|
89 | 90 | |
|
90 | 91 | # incorrect header |
|
91 | with open(path, 'w') as f: | |
|
92 | with open(path, 'wb') as f: | |
|
92 | 93 | f.write(b'NOT A VALID HEADER') |
|
93 | 94 | try: |
|
94 | 95 | revmap.revmap(path) |
@@ -106,8 +107,8 b' def testcorruptformat():' | |||
|
106 | 107 | |
|
107 | 108 | # corrupt the file by appending a byte |
|
108 | 109 | size = os.stat(path).st_size |
|
109 | with open(path, 'a') as f: | |
|
110 | f.write('\xff') | |
|
110 | with open(path, 'ab') as f: | |
|
111 | f.write(b'\xff') | |
|
111 | 112 | try: |
|
112 | 113 | revmap.revmap(path) |
|
113 | 114 | ensure(False) |
@@ -116,7 +117,7 b' def testcorruptformat():' | |||
|
116 | 117 | |
|
117 | 118 | # corrupt the file by removing the last byte |
|
118 | 119 | ensure(size > 0) |
|
119 | with open(path, 'w') as f: | |
|
120 | with open(path, 'wb') as f: | |
|
120 | 121 | f.truncate(size - 1) |
|
121 | 122 | try: |
|
122 | 123 | revmap.revmap(path) |
@@ -130,7 +131,8 b' def testcopyfrom():' | |||
|
130 | 131 | path = gettemppath() |
|
131 | 132 | rm = revmap.revmap(path) |
|
132 | 133 | for i in xrange(1, 10): |
|
133 |
ensure(rm.append(genhsh(i), |
|
|
134 | ensure(rm.append(genhsh(i), | |
|
135 | sidebranch=(i & 1), path=(b'%d' % (i // 3))) == i) | |
|
134 | 136 | rm.flush() |
|
135 | 137 | |
|
136 | 138 | # copy rm to rm2 |
@@ -174,10 +176,10 b' def testcontains():' | |||
|
174 | 176 | # "contains" checks paths |
|
175 | 177 | rm = revmap.revmap() |
|
176 | 178 | for i in xrange(1, 5): |
|
177 |
ensure(rm.append(genhsh(i), path= |
|
|
179 | ensure(rm.append(genhsh(i), path=(b'%d' % (i // 2))) == i) | |
|
178 | 180 | for i in xrange(1, 5): |
|
179 |
ensure(fakefctx(genhsh(i), path= |
|
|
180 | ensure(fakefctx(genhsh(i), path='a') not in rm) | |
|
181 | ensure(fakefctx(genhsh(i), path=(b'%d' % (i // 2))) in rm) | |
|
182 | ensure(fakefctx(genhsh(i), path=b'a') not in rm) | |
|
181 | 183 | |
|
182 | 184 | def testlastnode(): |
|
183 | 185 | path = gettemppath() |
@@ -186,7 +188,7 b' def testlastnode():' | |||
|
186 | 188 | ensure(revmap.getlastnode(path) is None) |
|
187 | 189 | for i in xrange(1, 10): |
|
188 | 190 | hsh = genhsh(i) |
|
189 |
rm.append(hsh, path= |
|
|
191 | rm.append(hsh, path=(b'%d' % (i // 2)), flush=True) | |
|
190 | 192 | ensure(revmap.getlastnode(path) == hsh) |
|
191 | 193 | rm2 = revmap.revmap(path) |
|
192 | 194 | ensure(rm2.rev2hsh(rm2.maxrev) == hsh) |
General Comments 0
You need to be logged in to leave comments.
Login now