From 1588b4111bc7124e7a0ebe5b18543a4fc41e00ea Mon Sep 17 00:00:00 2001 From: Luong Anh Tuan Date: Wed, 12 Oct 2016 11:54:37 +0700 Subject: [PATCH] Remove xrange for run both Python 2 and Python 3 In python 3, range() does what xrange() used to do and xrange() does not exist. If you want to write code that will run on both Python 2 and Python 3, you can't use xrange(). range() can actually be faster in some cases - eg. if iterating over the same sequence multiple times. xrange() has to reconstruct the integer object every time, but range() will have real integer objects. (It will always perform worse in terms of memory however) xrange() isn't usable in all cases where a real list is needed. For instance, it doesn't support slices, or any list methods. Change-Id: Ic08a009e4c8a57f8e958d80d22232f4ceb963b84 --- tests/test_inventory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_inventory.py b/tests/test_inventory.py index da4cd4e1dc..49e4671afd 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -446,7 +446,7 @@ class TestIps(unittest.TestCase): mock_open = mock.mock_open() - for i in xrange(0, 99): + for i in range(0, 99): # tearDown is ineffective for this loop, so clean the USED_IPs # on each run inventory = None