on xenial help sign in
Do python3 friendly range compat.
commitd442554bd4fa2e97f1922b074017e3c5d68a515e authorDimitri John Ledkov <dimitri.ledkov@canonical.com> dateSun 23 Feb 2014, 01:28 (13 years ago) parent163c594
2 files changed+12−6
tests/autopilot/unity8/shell/tests/test_notifications.py+5−4 tests/autopilot/unity8/shell/tests/test_upstart.py+7−2
tests/autopilot/unity8/shell/tests/test_notifications.py+5−4
@@ -37,9 +37,10 @@ import sys
3737
3838logger = logging.getLogger(__name__)
3939
40−# backwards compatible alias for Python 3
41−if sys.version > '3':
42− xrange = range
40+# from __future__ import range
41+# (python3's range, is same as python2's xrange)
42+if sys.version_info < (3,):
43+ range = xrange
4344
4445
4546class NotificationsBase(UnityTestCase):
@@ -304,7 +305,7 @@ class InteractiveNotificationBase(NotificationsBase):
304305 if self._notify_proc is None:
305306 raise AssertionError("No interactive notification was created.")
306307
307− for i in xrange(timeout):
308+ for i in range(timeout):
308309 self._notify_proc.poll()
309310 if self._notify_proc.returncode is not None:
310311 output = self._notify_proc.communicate()
tests/autopilot/unity8/shell/tests/test_upstart.py+7−2
@@ -36,7 +36,12 @@ import logging
3636
3737logger = logging.getLogger(__name__)
3838
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+
4045class UpstartIntegrationTests(UnityTestCase):
4146
4247 scenarios = _get_device_emulation_scenarios()
@@ -52,7 +57,7 @@ class UpstartIntegrationTests(UnityTestCase):
5257 self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args)
5358 def ensure_stopped():
5459 self.process.terminate()
55− for i in xrange(10):
60+ for i in range(10):
5661 try:
5762 self._get_status()
5863 except OSError: