D4176: tests: start moving test-parseindex2.py to a unittest

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Thu Aug 9 15:08:05 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG01966d45b45e: tests: start moving test-parseindex2.py to a unittest (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4176?vs=10108&id=10167

REVISION DETAIL
  https://phab.mercurial-scm.org/D4176

AFFECTED FILES
  tests/test-parseindex2.py

CHANGE DETAILS

diff --git a/tests/test-parseindex2.py b/tests/test-parseindex2.py
--- a/tests/test-parseindex2.py
+++ b/tests/test-parseindex2.py
@@ -8,6 +8,7 @@
 import struct
 import subprocess
 import sys
+import unittest
 
 from mercurial.node import (
     nullid,
@@ -155,8 +156,14 @@
 def makehex(major, minor, micro):
     return int("%x%02x%02x00" % (major, minor, micro), 16)
 
-def runversiontests():
+class parseindex2tests(unittest.TestCase):
+  def testversiondetection(self):
     """Check the version-detection logic when importing parsers."""
+    # Only test the version-detection logic if it is present.
+    try:
+        parsers.versionerrortext
+    except AttributeError:
+        return
     info = sys.version_info
     major, minor, micro = info[0], info[1], info[2]
     # Test same major-minor versions.
@@ -167,23 +174,16 @@
     testversionfail(4, makehex(major, minor + 1, micro))
     testversionfail(5, "'foo'")
 
-def runtest() :
-    # Only test the version-detection logic if it is present.
-    try:
-        parsers.versionerrortext
-    except AttributeError:
-        pass
-    else:
-        runversiontests()
-
+  def testbadargs(self):
     # Check that parse_index2() raises TypeError on bad arguments.
     try:
         parse_index2(0, True)
     except TypeError:
         pass
     else:
         print("Expected to get TypeError.")
 
+  def testparseindexfile(self):
    # Check parsers.parse_index2() on an index file against the original
    # Python implementation of parseindex, both with and without inlined data.
 
@@ -211,6 +211,7 @@
             # pure version doesn't support this
             break
 
+if __name__ == '__main__':
+    import silenttestrunner
+    silenttestrunner.main(__name__)
     print("done")
-
-runtest()



To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel


More information about the Mercurial-devel mailing list