on xenial help sign in
Ship python3 autopilot modules.
c6369c1Dimitri John Ledkov
cmake/modules/autopilot.cmake+10−1
@@ -2,7 +2,7 @@ add_custom_target(autopilot)
2
2
3function(declare_autopilot_test TEST_NAME TEST_SUITE WORKING_DIR)
3function(declare_autopilot_test TEST_NAME TEST_SUITE WORKING_DIR)
4 add_custom_target(autopilot-${TEST_NAME}
4 add_custom_target(autopilot-${TEST_NAME}
5− COMMAND LANG=C UBUNTU_ICON_THEME=ubuntu-mobile QML2_IMPORT_PATH=${SHELL_INSTALL_QML}/mocks autopilot run ${TEST_SUITE}
5+ COMMAND LANG=C UBUNTU_ICON_THEME=ubuntu-mobile QML2_IMPORT_PATH=${SHELL_INSTALL_QML}/mocks python3 -m autopilot.run run ${TEST_SUITE}
6 WORKING_DIRECTORY ${WORKING_DIR}
6 WORKING_DIRECTORY ${WORKING_DIR}
7 DEPENDS fake_install
7 DEPENDS fake_install
8 )
8 )
@@ -12,4 +12,13 @@ function(declare_autopilot_test TEST_NAME TEST_SUITE WORKING_DIR)
12 )
12 )
13
13
14 add_dependencies(autopilot autopilot-${TEST_NAME})
14 add_dependencies(autopilot autopilot-${TEST_NAME})
15+
16+ add_custom_target(autopilot2-${TEST_NAME}
17+ COMMAND LANG=C UBUNTU_ICON_THEME=ubuntu-mobile QML2_IMPORT_PATH=${SHELL_INSTALL_QML}/mocks python2 -m autopilot.run run ${TEST_SUITE}
18+ WORKING_DIRECTORY ${WORKING_DIR}
19+ DEPENDS fake_install
20+ )
21+
22+ add_dependencies(autopilot autopilot2-${TEST_NAME})
23+
15endfunction()
24endfunction()
debian/control+5
@@ -29,6 +29,7 @@ Build-Depends: cmake,
29 python:any (>= 2.7),
29 python:any (>= 2.7),
30 python-setuptools,
30 python-setuptools,
31 python3:any,
31 python3:any,
32+ python3-setuptools,
32 qt5-default,
33 qt5-default,
33 qtbase5-dev,
34 qtbase5-dev,
34 qtbase5-dev-tools,
35 qtbase5-dev-tools,
@@ -111,12 +112,16 @@ Depends: gir1.2-glib-2.0,
111 python-fixtures,
112 python-fixtures,
112 python-gi,
113 python-gi,
113 python-mock,
114 python-mock,
115+ python3-evdev,
116+ python3-fixtures,
117+ python3-gi,
114 ubuntu-ui-toolkit-autopilot,
118 ubuntu-ui-toolkit-autopilot,
115 unity8 (>= ${source:Version}),
119 unity8 (>= ${source:Version}),
116 unity8-fake-env (>= ${source:Version}),
120 unity8-fake-env (>= ${source:Version}),
117 url-dispatcher-tools,
121 url-dispatcher-tools,
118 ${misc:Depends},
122 ${misc:Depends},
119 ${python:Depends},
123 ${python:Depends},
124+ ${python3:Depends},
120 ${shlibs:Depends},
125 ${shlibs:Depends},
121Description: Test package for Unity 8 shell
126Description: Test package for Unity 8 shell
122 Autopilot tests for the unity8 package
127 Autopilot tests for the unity8 package
debian/rules+2−2
@@ -10,7 +10,7 @@ SCOPES_RECOMMENDS := $(shell perl debian/scopes-recommends-generator /usr/share/
10
10
11.PHONY: build
11.PHONY: build
12build %:
12build %:
13− dh $@ --parallel --fail-missing --with python2
13+ dh $@ --parallel --fail-missing --with python2,python3
14
14
15override_dh_auto_clean:
15override_dh_auto_clean:
16 dh_auto_clean
16 dh_auto_clean
@@ -28,7 +28,7 @@ override_dh_auto_build:
28override_dh_install:
28override_dh_install:
29 # install autopilot tests
29 # install autopilot tests
30 cd tests/autopilot; \
30 cd tests/autopilot; \
31− set -ex; for python in $(shell pyversions -r); do \
31+ set -ex; for python in $(shell pyversions -r) $(shell py3versions -r); do \
32 $$python setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb; \
32 $$python setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb; \
33 done; \
33 done; \
34 cd $(CURDIR)
34 cd $(CURDIR)
tests/autopilot/unity8/__init__.py+4−1
@@ -82,7 +82,10 @@ def get_binary_path(binary="unity8"):
82 )
82 )
83 if not os.path.exists(binary_path):
83 if not os.path.exists(binary_path):
84 try:
84 try:
85− binary_path = subprocess.check_output(['which', binary]).strip()
85+ binary_path = subprocess.check_output(
86+ ['which', binary],
87+ universal_newlines=True,
88+ ).strip()
86 except subprocess.CalledProcessError as e:
89 except subprocess.CalledProcessError as e:
87 raise RuntimeError("Unable to locate %s binary: %r" % (binary, e))
90 raise RuntimeError("Unable to locate %s binary: %r" % (binary, e))
88 return binary_path
91 return binary_path
tests/autopilot/unity8/shell/tests/__init__.py+12−13
@@ -85,12 +85,12 @@ class UnityTestCase(AutopilotTestCase):
85 @classmethod
85 @classmethod
86 def setUpClass(cls):
86 def setUpClass(cls):
87 try:
87 try:
88− output = subprocess.check_output([
88+ output = subprocess.check_output(
89− "/sbin/initctl",
89+ ["/sbin/initctl", "status", "unity8"],
90− "status",
91− "unity8"
92− ], stderr=subprocess.STDOUT)
90+ stderr=subprocess.STDOUT,
91+ universal_newlines=True,
92+ )
93− except subprocess.CalledProcessError, e:
93+ except subprocess.CalledProcessError as e:
94 sys.stderr.write(
94 sys.stderr.write(
95 "Error: `initctl status unity8` failed, most probably the "
95 "Error: `initctl status unity8` failed, most probably the "
96 "unity8 session could not be found:\n\n"
96 "unity8 session could not be found:\n\n"
@@ -218,12 +218,11 @@ class UnityTestCase(AutopilotTestCase):
218 def _patch_environment(self, key, value):
218 def _patch_environment(self, key, value):
219 """Wrapper for patching env for upstart environment."""
219 """Wrapper for patching env for upstart environment."""
220 try:
220 try:
221− current_value = subprocess.check_output([
221+ current_value = subprocess.check_output(
222− "/sbin/initctl",
222+ ["/sbin/initctl", "get-env", "--global", key],
223− "get-env",
224− "--global",
225− key
226− ], stderr=subprocess.STDOUT).rstrip()
223+ stderr=subprocess.STDOUT,
224+ universal_newlines=True,
225+ ).rstrip()
227 except subprocess.CalledProcessError:
226 except subprocess.CalledProcessError:
228 current_value = None
227 current_value = None
229
228
@@ -305,7 +304,7 @@ class UnityTestCase(AutopilotTestCase):
305
304
306 binary_arg = "BINARY=%s" % binary_path
305 binary_arg = "BINARY=%s" % binary_path
307 extra_args = "ARGS=%s" % " ".join(args)
306 extra_args = "ARGS=%s" % " ".join(args)
308− env_args = ["%s=%s" % (k, v) for k, v in self._environment.iteritems()]
307+ env_args = ["%s=%s" % (k, v) for k, v in self._environment.items()]
309 all_args = [binary_arg, extra_args] + env_args
308 all_args = [binary_arg, extra_args] + env_args
310
309
311 self.addCleanup(self._cleanup_launching_upstart_unity)
310 self.addCleanup(self._cleanup_launching_upstart_unity)
tests/autopilot/unity8/shell/tests/test_emulators.py+4−1
@@ -27,7 +27,10 @@ don't break them for those external projects.
27
27
28"""
28"""
29
29
30+try:
31+ from unittest import mock
32+except ImportError:
30−import mock
33+ import mock
31
34
32from testtools.matchers import Contains, HasLength
35from testtools.matchers import Contains, HasLength
33
36
tests/autopilot/unity8/shell/tests/test_lock_screen.py+18−3
@@ -26,12 +26,18 @@ from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
26
26
27from autopilot.matchers import Eventually
27from autopilot.matchers import Eventually
28from autopilot.platform import model
28from autopilot.platform import model
29+import sys
29from testtools import skipUnless
30from testtools import skipUnless
30from testtools.matchers import Equals
31from testtools.matchers import Equals
31import logging
32import logging
32
33
33logger = logging.getLogger(__name__)
34logger = logging.getLogger(__name__)
34
35
36+# py2 compatible alias for py3
37+if sys.version >= '3':
38+ basestring = str
39+
40+
35class TestLockscreen(UnityTestCase):
41class TestLockscreen(UnityTestCase):
36
42
37 """Tests for the lock screen."""
43 """Tests for the lock screen."""
@@ -125,7 +131,10 @@ class TestLockscreen(UnityTestCase):
125 """
131 """
126
132
127 if not isinstance(code, basestring):
133 if not isinstance(code, basestring):
134+ raise TypeError(
128− raise TypeError("'code' parameter must be a string.")
135+ "'code' parameter must be a string, not %r."
136+ % type(passphrase)
137+ )
129 for num in code:
138 for num in code:
130 if not num.isdigit():
139 if not num.isdigit():
131 raise ValueError(
140 raise ValueError(
@@ -142,7 +151,10 @@ class TestLockscreen(UnityTestCase):
142
151
143 """
152 """
144 if not isinstance(passphrase, basestring):
153 if not isinstance(passphrase, basestring):
154+ raise TypeError(
145− raise TypeError("'passphrase' parameter must be a string.")
155+ "'passphrase' parameter must be a string, not %r."
156+ % type(passphrase)
157+ )
146
158
147 pinentryField = self.main_window.get_pinentryField()
159 pinentryField = self.main_window.get_pinentryField()
148 self.touch.tap_object(pinentryField)
160 self.touch.tap_object(pinentryField)
@@ -161,7 +173,10 @@ class TestLockscreen(UnityTestCase):
161
173
162 """
174 """
163 if not isinstance(passphrase, basestring):
175 if not isinstance(passphrase, basestring):
176+ raise TypeError(
164− raise TypeError("'passphrase' parameter must be a string.")
177+ "'passphrase' parameter must be a string, not %r."
178+ % type(passphrase)
179+ )
165
180
166 prompt = self.main_window.get_greeter().get_prompt()
181 prompt = self.main_window.get_greeter().get_prompt()
167 self.touch.tap_object(prompt)
182 self.touch.tap_object(prompt)
tests/autopilot/unity8/shell/tests/test_notifications.py+6
@@ -33,9 +33,14 @@ import os
33import logging
33import logging
34import signal
34import signal
35import subprocess
35import subprocess
36+import sys
36
37
37logger = logging.getLogger(__name__)
38logger = logging.getLogger(__name__)
38
39
40+# backwards compatible alias for Python 3
41+if sys.version > '3':
42+ xrange = range
43+
39
44
40class NotificationsBase(UnityTestCase):
45class NotificationsBase(UnityTestCase):
41 """Base class for all notification tests that provides helper methods."""
46 """Base class for all notification tests that provides helper methods."""
@@ -261,6 +266,7 @@ class InteractiveNotificationBase(NotificationsBase):
261 stdout=subprocess.PIPE,
266 stdout=subprocess.PIPE,
262 stderr=subprocess.PIPE,
267 stderr=subprocess.PIPE,
263 close_fds=True,
268 close_fds=True,
269+ universal_newlines=True,
264 )
270 )
265
271
266 self.addCleanup(self._tidy_up_script_process)
272 self.addCleanup(self._tidy_up_script_process)