on xenial help sign in
Do python3 friendly range compat.
d442554Dimitri John Ledkov
tests/autopilot/unity8/shell/tests/test_notifications.py+5−4
@@ -37,9 +37,10 @@ import sys
37
37
38logger = logging.getLogger(__name__)
38logger = logging.getLogger(__name__)
39
39
40−# backwards compatible alias for Python 3
40+# from __future__ import range
41−if sys.version > '3':
41+# (python3's range, is same as python2's xrange)
42− xrange = range
42+if sys.version_info < (3,):
43+ range = xrange
43
44
44
45
45class NotificationsBase(UnityTestCase):
46class NotificationsBase(UnityTestCase):
@@ -304,7 +305,7 @@ class InteractiveNotificationBase(NotificationsBase):
304 if self._notify_proc is None:
305 if self._notify_proc is None:
305 raise AssertionError("No interactive notification was created.")
306 raise AssertionError("No interactive notification was created.")
306
307
307− for i in xrange(timeout):
308+ for i in range(timeout):
308 self._notify_proc.poll()
309 self._notify_proc.poll()
309 if self._notify_proc.returncode is not None:
310 if self._notify_proc.returncode is not None:
310 output = self._notify_proc.communicate()
311 output = self._notify_proc.communicate()
tests/autopilot/unity8/shell/tests/test_upstart.py+7−2
@@ -36,7 +36,12 @@ import logging
36
36
37logger = logging.getLogger(__name__)
37logger = logging.getLogger(__name__)
38
38
39−
39+# from __future__ import range
40+# (python3's range, is same as python2's xrange)
41+import sys
42+if sys.version_info < (3,):
43+ range = xrange
44+
40class UpstartIntegrationTests(UnityTestCase):
45class UpstartIntegrationTests(UnityTestCase):
41
46
42 scenarios = _get_device_emulation_scenarios()
47 scenarios = _get_device_emulation_scenarios()
@@ -52,7 +57,7 @@ class UpstartIntegrationTests(UnityTestCase):
52 self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args)
57 self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args)
53 def ensure_stopped():
58 def ensure_stopped():
54 self.process.terminate()
59 self.process.terminate()
55− for i in xrange(10):
60+ for i in range(10):
56 try:
61 try:
57 self._get_status()
62 self._get_status()
58 except OSError:
63 except OSError: