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

login
register
mail settings
Submitter Augie Fackler
Date Sept. 19, 2017, 4:35 a.m.
Message ID <920c56d5f84cd54395a2.1505795718@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/24007/
State Accepted
Headers show

Comments

Augie Fackler - Sept. 19, 2017, 4:35 a.m.
# HG changeset patch
# User Augie Fackler <augie@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.
Yuya Nishihara - Sept. 19, 2017, 3:32 p.m.
On Tue, 19 Sep 2017 00:35:18 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@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

Queued, thanks.

Patch

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)