]> git.sur5r.net Git - u-boot/commitdiff
test/py: Use range() rather than xrange()
authorPaul Burton <paul.burton@imgtec.com>
Thu, 14 Sep 2017 21:34:44 +0000 (14:34 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 10 Jul 2018 20:50:50 +0000 (14:50 -0600)
In python 3.x the xrange() function has been removed, and range()
returns an iterator much like Python 2.x's xrange(). Simply use range()
in place of xrange() in order to work on both python 2.x & 3.x. This
will mean a small cost on python 2.x since range() will return a list
there rather than an iterator, but the cost should be negligible.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
test/py/u_boot_console_sandbox.py
test/py/u_boot_spawn.py
test/py/u_boot_utils.py

index c901397e1c1fedc8e555a58a1d47d7046a092f31..778f6d0983d621e86a16ae825d20dc5b5ee7defc 100644 (file)
@@ -81,7 +81,7 @@ class ConsoleSandbox(ConsoleBase):
 
         p = self.p
         self.p = None
-        for i in xrange(100):
+        for i in range(100):
             ret = not p.isalive()
             if ret:
                 break
index 77a010a33f0cca26c870c72dc7204d42f8587f2c..b011a3e3da255f5301163973bc52f72af9da3a32 100644 (file)
@@ -134,7 +134,7 @@ class Spawn(object):
             the expected time.
         """
 
-        for pi in xrange(len(patterns)):
+        for pi in range(len(patterns)):
             if type(patterns[pi]) == type(''):
                 patterns[pi] = re.compile(patterns[pi])
 
@@ -143,7 +143,7 @@ class Spawn(object):
             while True:
                 earliest_m = None
                 earliest_pi = None
-                for pi in xrange(len(patterns)):
+                for pi in range(len(patterns)):
                     pattern = patterns[pi]
                     m = pattern.search(self.buf)
                     if not m:
@@ -198,7 +198,7 @@ class Spawn(object):
         """
 
         os.close(self.fd)
-        for i in xrange(100):
+        for i in range(100):
             if not self.isalive():
                 break
             time.sleep(0.1)
index bb31e57b279993e3de4055bee6d0ff6a2a8d1dd0..d68d1dd10541d963e93c610d9a684330c72c9830 100644 (file)
@@ -120,7 +120,7 @@ def wait_until_open_succeeds(fn):
         An open file handle to the file.
     """
 
-    for i in xrange(100):
+    for i in range(100):
         fh = attempt_to_open_file(fn)
         if fh:
             return fh
@@ -143,7 +143,7 @@ def wait_until_file_open_fails(fn, ignore_errors):
         Nothing.
     """
 
-    for i in xrange(100):
+    for i in range(100):
         fh = attempt_to_open_file(fn)
         if not fh:
             return