From patchwork Tue Mar 8 05:33:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,6] hghave: check the mercurial.modulepolicy for pure From: timeless@mozdev.org X-Patchwork-Id: 13664 Message-Id: <49a623b73dd3cceb46f0.1457415199@waste.org> To: mercurial-devel@mercurial-scm.org Date: Mon, 07 Mar 2016 23:33:19 -0600 # HG changeset patch # User timeless # 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",