# HG changeset patch # User FUJIWARA Katsunori # Date 2013-10-04 16:02:22 # Node ID 8bbe208c181228b7974b98e62e1732d2263d6b4d # Parent b8316878a685d27d2b5eb9f5576eb3de58b61e8e 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. diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -282,6 +282,9 @@ def has_absimport(): 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 @@ checks = { "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"), }