##// END OF EJS Templates
tests: fix up indent width in test-parseindex2.py...
Augie Fackler -
r39026:087a7553 default
parent child Browse files
Show More
@@ -157,59 +157,60 b' def makehex(major, minor, micro):'
157 return int("%x%02x%02x00" % (major, minor, micro), 16)
157 return int("%x%02x%02x00" % (major, minor, micro), 16)
158
158
159 class parseindex2tests(unittest.TestCase):
159 class parseindex2tests(unittest.TestCase):
160 def testversiondetection(self):
160 def testversiondetection(self):
161 """Check the version-detection logic when importing parsers."""
161 """Check the version-detection logic when importing parsers."""
162 # Only test the version-detection logic if it is present.
162 # Only test the version-detection logic if it is present.
163 try:
163 try:
164 parsers.versionerrortext
164 parsers.versionerrortext
165 except AttributeError:
165 except AttributeError:
166 return
166 return
167 info = sys.version_info
167 info = sys.version_info
168 major, minor, micro = info[0], info[1], info[2]
168 major, minor, micro = info[0], info[1], info[2]
169 # Test same major-minor versions.
169 # Test same major-minor versions.
170 testversionokay(1, makehex(major, minor, micro))
170 testversionokay(1, makehex(major, minor, micro))
171 testversionokay(2, makehex(major, minor, micro + 1))
171 testversionokay(2, makehex(major, minor, micro + 1))
172 # Test different major-minor versions.
172 # Test different major-minor versions.
173 testversionfail(3, makehex(major + 1, minor, micro))
173 testversionfail(3, makehex(major + 1, minor, micro))
174 testversionfail(4, makehex(major, minor + 1, micro))
174 testversionfail(4, makehex(major, minor + 1, micro))
175 testversionfail(5, "'foo'")
175 testversionfail(5, "'foo'")
176
176
177 def testbadargs(self):
177 def testbadargs(self):
178 # Check that parse_index2() raises TypeError on bad arguments.
178 # Check that parse_index2() raises TypeError on bad arguments.
179 try:
179 try:
180 parse_index2(0, True)
180 parse_index2(0, True)
181 except TypeError:
181 except TypeError:
182 pass
182 pass
183 else:
183 else:
184 print("Expected to get TypeError.")
184 print("Expected to get TypeError.")
185
185
186 def testparseindexfile(self):
186 def testparseindexfile(self):
187 # Check parsers.parse_index2() on an index file against the original
187 # Check parsers.parse_index2() on an index file against the
188 # Python implementation of parseindex, both with and without inlined data.
188 # original Python implementation of parseindex, both with and
189 # without inlined data.
189
190
190 py_res_1 = py_parseindex(data_inlined, True)
191 py_res_1 = py_parseindex(data_inlined, True)
191 c_res_1 = parse_index2(data_inlined, True)
192 c_res_1 = parse_index2(data_inlined, True)
192
193
193 py_res_2 = py_parseindex(data_non_inlined, False)
194 py_res_2 = py_parseindex(data_non_inlined, False)
194 c_res_2 = parse_index2(data_non_inlined, False)
195 c_res_2 = parse_index2(data_non_inlined, False)
195
196
196 if py_res_1 != c_res_1:
197 if py_res_1 != c_res_1:
197 print("Parse index result (with inlined data) differs!")
198 print("Parse index result (with inlined data) differs!")
198
199
199 if py_res_2 != c_res_2:
200 if py_res_2 != c_res_2:
200 print("Parse index result (no inlined data) differs!")
201 print("Parse index result (no inlined data) differs!")
201
202
202 ix = parsers.parse_index2(data_inlined, True)[0]
203 ix = parsers.parse_index2(data_inlined, True)[0]
203 for i, r in enumerate(ix):
204 for i, r in enumerate(ix):
204 if r[7] == nullid:
205 if r[7] == nullid:
205 i = -1
206 i = -1
206 try:
207 try:
207 if ix[r[7]] != i:
208 if ix[r[7]] != i:
208 print('Reverse lookup inconsistent for %r'
209 print('Reverse lookup inconsistent for %r'
209 % r[7].encode('hex'))
210 % r[7].encode('hex'))
210 except TypeError:
211 except TypeError:
211 # pure version doesn't support this
212 # pure version doesn't support this
212 break
213 break
213
214
214 if __name__ == '__main__':
215 if __name__ == '__main__':
215 import silenttestrunner
216 import silenttestrunner
General Comments 0
You need to be logged in to leave comments. Login now