[PATCH 1 of 8] tests: fix run-tests default values in Test constructor

Augie Fackler raf at durin42.com
Tue Sep 19 04:35:18 UTC 2017


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1505794017 14400
#      Tue Sep 19 00:06:57 2017 -0400
# Node ID 920c56d5f84cd54395a22cce9d0cc79216ed4cf2
# Parent  1533371769b5ad3de2c7aa1ed08ee7cfb99c0c91
tests: fix run-tests default values in Test constructor

As far as I can tell, default values are evaluated far earlier on
Python 3.6 than 2.7, meaning we've got to be more careful about when
we read the defaults dictionary for the kwarg defaults. Sigh.

With this change, test-run-tests.t is significantly less of a mess
under 3.6.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -659,10 +659,10 @@ class Test(unittest.TestCase):
 
     def __init__(self, path, outputdir, tmpdir, keeptmpdir=False,
                  debug=False,
-                 timeout=defaults['timeout'],
-                 startport=defaults['port'], extraconfigopts=None,
+                 timeout=None,
+                 startport=None, extraconfigopts=None,
                  py3kwarnings=False, shell=None, hgcommand=None,
-                 slowtimeout=defaults['slowtimeout'], usechg=False,
+                 slowtimeout=None, usechg=False,
                  useipv6=False):
         """Create a test from parameters.
 
@@ -694,6 +694,12 @@ class Test(unittest.TestCase):
 
         shell is the shell to execute tests in.
         """
+        if timeout is None:
+            timeout = defaults['timeout']
+        if startport is None:
+            startport = defaults['port']
+        if slowtimeout is None:
+            slowtimeout = defaults['slowtimeout']
         self.path = path
         self.bname = os.path.basename(path)
         self.name = _strpath(self.bname)


More information about the Mercurial-devel mailing list