Bug 1348872 - Wait() should accept None as timeout and interval. draft
authorHenrik Skupin <mail@hskupin.info>
Tue, 28 Mar 2017 22:47:43 +0200
changeset 552699 6b0d43b9d891fd7173efc548d081756146d12b1c
parent 552448 82d8355fbf5675216eb7717916b9941616ed2e4b
child 552700 17510b4defd7ebcacb66e2a153d047fbdd598935
push id51424
push userbmo:hskupin@gmail.com
push dateTue, 28 Mar 2017 20:52:34 +0000
bugs1348872
milestone55.0a1
Bug 1348872 - Wait() should accept None as timeout and interval. Setting the default value for both the timeout and interval should not be done in the parameter list, but dependent on if None is passed in or not. MozReview-Commit-ID: 4VwHfTkrwDk
testing/marionette/client/marionette_driver/wait.py
--- a/testing/marionette/client/marionette_driver/wait.py
+++ b/testing/marionette/client/marionette_driver/wait.py
@@ -24,18 +24,18 @@ class Wait(object):
     condition, as well as the frequency with which to check the
     condition.  Furthermore, the user may configure the wait to ignore
     specific types of exceptions whilst waiting, such as
     `errors.NoSuchElementException` when searching for an element on
     the page.
 
     """
 
-    def __init__(self, marionette, timeout=DEFAULT_TIMEOUT,
-                 interval=DEFAULT_INTERVAL, ignored_exceptions=None,
+    def __init__(self, marionette, timeout=None,
+                 interval=None, ignored_exceptions=None,
                  clock=None):
         """Configure the Wait instance to have a custom timeout, interval, and
         list of ignored exceptions.  Optionally a different time
         implementation than the one provided by the standard library
         (time) can also be provided.
 
         Sample usage::
 
@@ -66,20 +66,20 @@ class Wait(object):
 
         :param clock: Allows overriding the use of the runtime's
             default time library.  See `wait.SystemClock` for
             implementation details.
 
         """
 
         self.marionette = marionette
-        self.timeout = timeout
+        self.timeout = timeout if timeout is not None else DEFAULT_TIMEOUT
+        self.interval = interval if interval is not None else DEFAULT_INTERVAL
         self.clock = clock or SystemClock()
         self.end = self.clock.now + self.timeout
-        self.interval = interval
 
         exceptions = []
         if ignored_exceptions is not None:
             if isinstance(ignored_exceptions, collections.Iterable):
                 exceptions.extend(iter(ignored_exceptions))
             else:
                 exceptions.append(ignored_exceptions)
         self.exceptions = tuple(set(exceptions))