diff --git a/tests/hghave.py b/tests/hghave.py
index a5ce381a8da0d03c8f275a46b34b07f3a90369c7_dGVzdHMvaGdoYXZlLnB5..b05a3a04f046a75ec1bbff08b1ecd8acc2f481fe_dGVzdHMvaGdoYXZlLnB5 100644
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -530,6 +530,10 @@
                          br'other supported Python versions')
     return dpkg and dh and dh_py2
 
+@check("demandimport", "demandimport enabled")
+def has_demandimport():
+    return os.environ.get('HGDEMANDIMPORT') != 'disable'
+
 @check("absimport", "absolute_import in __future__")
 def has_absimport():
     import __future__