##// END OF EJS Templates
tests: start moving test-parseindex2.py to a unittest...
Augie Fackler -
r39025:01966d45 default
parent child Browse files
Show More
@@ -8,6 +8,7 b' from __future__ import absolute_import, '
8 import struct
8 import struct
9 import subprocess
9 import subprocess
10 import sys
10 import sys
11 import unittest
11
12
12 from mercurial.node import (
13 from mercurial.node import (
13 nullid,
14 nullid,
@@ -155,8 +156,14 b' def testversionfail(testnumber, hexversi'
155 def makehex(major, minor, micro):
156 def makehex(major, minor, micro):
156 return int("%x%02x%02x00" % (major, minor, micro), 16)
157 return int("%x%02x%02x00" % (major, minor, micro), 16)
157
158
158 def runversiontests():
159 class parseindex2tests(unittest.TestCase):
160 def testversiondetection(self):
159 """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.
163 try:
164 parsers.versionerrortext
165 except AttributeError:
166 return
160 info = sys.version_info
167 info = sys.version_info
161 major, minor, micro = info[0], info[1], info[2]
168 major, minor, micro = info[0], info[1], info[2]
162 # Test same major-minor versions.
169 # Test same major-minor versions.
@@ -167,15 +174,7 b' def runversiontests():'
167 testversionfail(4, makehex(major, minor + 1, micro))
174 testversionfail(4, makehex(major, minor + 1, micro))
168 testversionfail(5, "'foo'")
175 testversionfail(5, "'foo'")
169
176
170 def runtest() :
177 def testbadargs(self):
171 # Only test the version-detection logic if it is present.
172 try:
173 parsers.versionerrortext
174 except AttributeError:
175 pass
176 else:
177 runversiontests()
178
179 # Check that parse_index2() raises TypeError on bad arguments.
178 # Check that parse_index2() raises TypeError on bad arguments.
180 try:
179 try:
181 parse_index2(0, True)
180 parse_index2(0, True)
@@ -184,6 +183,7 b' def runtest() :'
184 else:
183 else:
185 print("Expected to get TypeError.")
184 print("Expected to get TypeError.")
186
185
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 original
188 # Python implementation of parseindex, both with and without inlined data.
188 # Python implementation of parseindex, both with and without inlined data.
189
189
@@ -211,6 +211,7 b' def runtest() :'
211 # pure version doesn't support this
211 # pure version doesn't support this
212 break
212 break
213
213
214 if __name__ == '__main__':
215 import silenttestrunner
216 silenttestrunner.main(__name__)
214 print("done")
217 print("done")
215
216 runtest()
General Comments 0
You need to be logged in to leave comments. Login now