diff tests/test-parseindex2.py @ 20159:96b2dd77c85d

parsers: backout version mismatch detection from 21dafd8546d1 This introduced mandatory recompilations and breaks pure mode in tests
author Matt Mackall <mpm@selenic.com>
date Sun, 01 Dec 2013 20:46:36 -0600
parents 21dafd8546d1
children 7eda5bb9ec8f
line wrap: on
line diff
--- a/tests/test-parseindex2.py	Sun Dec 01 14:10:53 2013 -0600
+++ b/tests/test-parseindex2.py	Sun Dec 01 20:46:36 2013 -0600
@@ -1,8 +1,6 @@
 from mercurial import parsers
 from mercurial.node import nullid, nullrev
 import struct
-import subprocess
-import sys
 
 # This unit test compares the return value of the original Python
 # implementation of parseindex and the new C implementation for
@@ -99,62 +97,7 @@
     index, chunkcache = parsers.parse_index2(data, inline)
     return list(index), chunkcache
 
-def importparsers(hexversion):
-    """Import mercurial.parsers with the given sys.hexversion."""
-    # The file parsers.c inspects sys.hexversion to determine the version
-    # of the currently-running Python interpreter, so we monkey-patch
-    # sys.hexversion to simulate using different versions.
-    code = ("import sys; sys.hexversion=%s; "
-            "import mercurial.parsers" % hexversion)
-    cmd = "python -c \"%s\"" % code
-    # We need to do these tests inside a subprocess because parser.c's
-    # version-checking code happens inside the module init function, and
-    # when using reload() to reimport an extension module, "The init function
-    # of extension modules is not called a second time"
-    # (from http://docs.python.org/2/library/functions.html?#reload).
-    p = subprocess.Popen(cmd, shell=True,
-                         stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-    return p.communicate()  # returns stdout, stderr
-
-def printhexfail(testnumber, hexversion, msg):
-    try:
-        hexstring = hex(hexversion)
-    except TypeError:
-        hexstring = None
-    print ("%s) using Python %s and patched sys.hexversion %r (%r): %s" %
-           (testnumber, sys.version_info, hexversion, hexstring, msg))
-
-def testversionokay(testnumber, hexversion):
-    stdout, stderr = importparsers(hexversion)
-    if stdout:
-        printhexfail(testnumber, hexversion,
-                     "Expected no stdout but got: %r" % stdout)
-
-def testversionfail(testnumber, hexversion):
-    stdout, stderr = importparsers(hexversion)
-    if not "ImportError: Python minor version mismatch" in stdout:
-        printhexfail(testnumber, hexversion,
-                     "Expected stdout to contain %r but got: %r" %
-                     (errstring, stdout))
-
-def makehex(major, minor, micro):
-    return int("%x%02x%02x00" % (major, minor, micro), 16)
-
-def runversiontests():
-    """Test importing parsers using different Python versions."""
-    info = sys.version_info
-    major, minor, micro = info[0], info[1], info[2]
-    # Test same major-minor versions.
-    testversionokay(1, makehex(major, minor, micro))
-    testversionokay(2, makehex(major, minor, micro + 1))
-    # Test different major-minor versions.
-    testversionfail(3, makehex(major + 1, minor, micro))
-    testversionfail(4, makehex(major, minor + 1, micro))
-    testversionfail(5, "'foo'")
-
 def runtest() :
-    runversiontests()
-
     # Check that parse_index2() raises TypeError on bad arguments.
     try:
         parse_index2(0, True)