changeset 19931:8bbe208c1812

hghave: add "py3k" feature to check whether test runs with Python 3.x This patch adds "py3k" feature to check whether test runs with Python 3.x. This check is needed for portability of test code: for example, in the default, modules are imported relatively first with python 2.x, but imported absolutely with Python 3.x.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 05 Oct 2013 01:02:22 +0900
parents b8316878a685
children e3a5922e18c3
files tests/hghave.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/hghave.py	Sat Oct 05 01:02:22 2013 +0900
+++ b/tests/hghave.py	Sat Oct 05 01:02:22 2013 +0900
@@ -282,6 +282,9 @@
     from mercurial import util
     return util.safehasattr(__future__, "absolute_import")
 
+def has_py3k():
+    return 3 == sys.version_info[0]
+
 checks = {
     "true": (lambda: True, "yak shaving"),
     "false": (lambda: False, "nail clipper"),
@@ -324,4 +327,5 @@
     "msys": (has_msys, "Windows with MSYS"),
     "aix": (has_aix, "AIX"),
     "absimport": (has_absimport, "absolute_import in __future__"),
+    "py3k": (has_py3k, "running with Python 3.x"),
 }