[PATCH 2 of 7 v2] hghave: check the mercurial.modulepolicy for pure

timeless timeless at mozdev.org
Mon Jan 11 23:23:04 CST 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1452574111 0
#      Tue Jan 12 04:48:31 2016 +0000
# Node ID a55eb78c1f0697d658ba78f67641746a4bf119e5
# Parent  39122c2442cd445172d7f07adb3f8186f9ddc0f1
hghave: check the mercurial.modulepolicy for pure

This is the most "correct" way to find out if we are running pure,
but I am not sure about paths/loading the mercurial module in hghave...

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -460,6 +460,14 @@
 
 @check("pure", "running with pure Python code")
 def has_pure():
+    try:
+        parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+        sys.path.insert(0, parent)
+        import mercurial
+        if mercurial.modulepolicy == 'py':
+            return True
+    finally:
+        del sys.path[0]
     return any([
         os.environ.get("HGMODULEPOLICY") == "py",
         os.environ.get("HGTEST_RUN_TESTS_PURE") == "--pure",


More information about the Mercurial-devel mailing list