[PATCH 1 of 6] hghave: check the mercurial.modulepolicy for pure

timeless timeless at mozdev.org
Tue Mar 8 00:33:19 EST 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1452574111 0
#      Tue Jan 12 04:48:31 2016 +0000
# Node ID 49a623b73dd3cceb46f088006d005e2314c056bb
# Parent  9974b8236cac50945d7b529e7c4fae9cf4974443
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
@@ -445,6 +445,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