Merge lp:~veebers/unity8/update_ap_tests_ready_for_py3 into lp:unity8
- update_ap_tests_ready_for_py3
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Albert Astals Cid |
Proposed branch: | lp:~veebers/unity8/update_ap_tests_ready_for_py3 |
Merge into: | lp:unity8 |
Diff against target: |
192 lines (+68/-17) 6 files modified
.bzrignore (+3/-0) tests/autopilot/tox.ini (+25/-0) tests/autopilot/unity8/__init__.py (+4/-1) tests/autopilot/unity8/shell/tests/__init__.py (+12/-13) tests/autopilot/unity8/shell/tests/test_lock_screen.py (+18/-3) tests/autopilot/unity8/shell/tests/test_notifications.py (+6/-0) |
To merge this branch: | bzr merge lp:~veebers/unity8/update_ap_tests_ready_for_py3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid (community) | Disapprove | ||
Christopher Lee (community) | Needs Fixing | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Michał Sawicz | Needs Fixing | ||
Martin Pitt | Approve | ||
Review via email: mp+194655@code.launchpad.net |
Commit message
Update the autopilot tests (and emulators) to make them compatible with python 3.
Description of the change
Update the autopilot tests (and emulators) to make them compatible with python 3.
Christopher Lee (veebers) wrote : | # |
Hi Martin,
I've updated the code addressing the issues highlighted in your review.
(the str/basestring change I took from the autopilot py3 update).
I ran the tests with both py2 && py3 using tox (that is also introduced in this MR).
Martin Pitt (pitti) wrote : | # |
I can't speak about the new tox file (I never used that, and it seems a little redundant to me), but the actual porting looks good now, thank you!
Christopher Lee (veebers) wrote : | # |
The intention with the tox integration is to make it easy for people to run any tests they create or modify and ensure they run under py2 && py3. At least until we are py3 only then it should be removed.
Perhaps there is a better way to do so? I'm open to suggestions.
Martin Pitt (pitti) wrote : | # |
Don't get me wrong, I'm not saying it's bad. Just that I haven't used it so far and thus I don't know it. I usually just call the tests directly with python2/python3 in debian/tests/, debian/rules, "do-release" scripts, or wherever appropriate.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:524
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:524
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:524
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:524
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michał Sawicz (saviq) wrote : | # |
Tox executes:
autopilot run unity8.tests
But that matches 0 tests.
- 525. By Christopher Lee
-
Merge Trunk
- 526. By Christopher Lee
-
Fix typo in args string
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:526
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Christopher Lee (veebers) wrote : | # |
This will need a packaging change too that will install a python3 version as well (otherwise the py3 changes are useless at this stage).
Martin Pitt (pitti) wrote : | # |
I thought we wanted land this first, as we *will* cause failures during CI test running if we pull in python3-autopilot at this point. Francis wanted some package to experiment with to teach the CI infrastructure about using "autopilot" vs. "autopilot-py3" according to the dependencies, but that's not there yet.
Michał Sawicz (saviq) wrote : | # |
I thought that was the idea, too - that's why we're doing it so that it works with py2 and py3? So that we can easily flip the switch later?
Christopher Lee (veebers) wrote : | # |
Right, I think I need to clarify what I had intended.
I noticed that the changes made here cannot be consumed by other python3 versions of tests when I started checking the compatibility of the ubuntu-keyboard tests that use the unity8.
This is why I wanted to change the packaging so that the tests, and more importantly the emulators, were installed for python 2 and python 3 (so I could proceed with the u-kb stuff).
This comment made on the ui-toolkit is topical: https:/
(effectively either split into 2 packages or insanity of dual-installation).
I get the feeling that at this stage that I should alter what I have so that it is split into 2 packages.
Michał Sawicz (saviq) wrote : | # |
Hey Chris, any word on this?
Dimitri John Ledkov (xnox) wrote : | # |
Merged into and superseeded by https:/
Albert Astals Cid (aacid) wrote : | # |
Rejecting based on Dimitri's comment
Unmerged revisions
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2013-06-28 20:27:17 +0000 | |||
3 | +++ .bzrignore 2013-11-19 19:38:26 +0000 | |||
4 | @@ -8,3 +8,6 @@ | |||
5 | 8 | /.settings | 8 | /.settings |
6 | 9 | /.pydevproject | 9 | /.pydevproject |
7 | 10 | message.txt | 10 | message.txt |
8 | 11 | # tox/python/autopilot | ||
9 | 12 | tests/autopilot/unity.egg-info | ||
10 | 13 | tests/autopilot/.tox | ||
11 | 11 | 14 | ||
12 | === added file 'tests/autopilot/tox.ini' | |||
13 | --- tests/autopilot/tox.ini 1970-01-01 00:00:00 +0000 | |||
14 | +++ tests/autopilot/tox.ini 2013-11-19 19:38:26 +0000 | |||
15 | @@ -0,0 +1,25 @@ | |||
16 | 1 | # Tox (http://tox.testrun.org/) is a tool for running tests | ||
17 | 2 | # in multiple virtualenvs. This configuration file will run the | ||
18 | 3 | # test suite on all supported python versions. | ||
19 | 4 | # | ||
20 | 5 | # To use it, install the `tox` python package: | ||
21 | 6 | # "sudo pip install tox" or "sudo apt-get install python-tox" | ||
22 | 7 | # then run "tox" from this directory. | ||
23 | 8 | |||
24 | 9 | |||
25 | 10 | [tox] | ||
26 | 11 | envlist = flake8, py27, py33 | ||
27 | 12 | |||
28 | 13 | [flake8] | ||
29 | 14 | exclude = .tox | ||
30 | 15 | |||
31 | 16 | [testenv] | ||
32 | 17 | sitepackages = True | ||
33 | 18 | commands = | ||
34 | 19 | autopilot run {posargs:unity8} | ||
35 | 20 | |||
36 | 21 | [testenv:flake8] | ||
37 | 22 | deps = | ||
38 | 23 | flake8 | ||
39 | 24 | commands = | ||
40 | 25 | flake8 | ||
41 | 0 | 26 | ||
42 | === modified file 'tests/autopilot/unity8/__init__.py' | |||
43 | --- tests/autopilot/unity8/__init__.py 2013-10-17 09:01:20 +0000 | |||
44 | +++ tests/autopilot/unity8/__init__.py 2013-11-19 19:38:26 +0000 | |||
45 | @@ -82,7 +82,10 @@ | |||
46 | 82 | ) | 82 | ) |
47 | 83 | if not os.path.exists(binary_path): | 83 | if not os.path.exists(binary_path): |
48 | 84 | try: | 84 | try: |
50 | 85 | binary_path = subprocess.check_output(['which', binary]).strip() | 85 | binary_path = subprocess.check_output( |
51 | 86 | ['which', binary], | ||
52 | 87 | universal_newlines=True, | ||
53 | 88 | ).strip() | ||
54 | 86 | except subprocess.CalledProcessError as e: | 89 | except subprocess.CalledProcessError as e: |
55 | 87 | raise RuntimeError("Unable to locate %s binary: %r" % (binary, e)) | 90 | raise RuntimeError("Unable to locate %s binary: %r" % (binary, e)) |
56 | 88 | return binary_path | 91 | return binary_path |
57 | 89 | 92 | ||
58 | === modified file 'tests/autopilot/unity8/shell/tests/__init__.py' | |||
59 | --- tests/autopilot/unity8/shell/tests/__init__.py 2013-11-01 13:59:50 +0000 | |||
60 | +++ tests/autopilot/unity8/shell/tests/__init__.py 2013-11-19 19:38:26 +0000 | |||
61 | @@ -86,12 +86,12 @@ | |||
62 | 86 | @classmethod | 86 | @classmethod |
63 | 87 | def setUpClass(cls): | 87 | def setUpClass(cls): |
64 | 88 | try: | 88 | try: |
71 | 89 | output = subprocess.check_output([ | 89 | output = subprocess.check_output( |
72 | 90 | "/sbin/initctl", | 90 | ["/sbin/initctl", "status", "unity8"], |
73 | 91 | "status", | 91 | stderr=subprocess.STDOUT, |
74 | 92 | "unity8" | 92 | universal_newlines=True, |
75 | 93 | ], stderr=subprocess.STDOUT) | 93 | ) |
76 | 94 | except subprocess.CalledProcessError, e: | 94 | except subprocess.CalledProcessError as e: |
77 | 95 | sys.stderr.write( | 95 | sys.stderr.write( |
78 | 96 | "Error: `initctl status unity8` failed, most probably the " | 96 | "Error: `initctl status unity8` failed, most probably the " |
79 | 97 | "unity8 session could not be found:\n\n" | 97 | "unity8 session could not be found:\n\n" |
80 | @@ -219,12 +219,11 @@ | |||
81 | 219 | def _patch_environment(self, key, value): | 219 | def _patch_environment(self, key, value): |
82 | 220 | """Wrapper for patching env for upstart environment.""" | 220 | """Wrapper for patching env for upstart environment.""" |
83 | 221 | try: | 221 | try: |
90 | 222 | current_value = subprocess.check_output([ | 222 | current_value = subprocess.check_output( |
91 | 223 | "/sbin/initctl", | 223 | ["/sbin/initctl", "get-env", "--global", key], |
92 | 224 | "get-env", | 224 | stderr=subprocess.STDOUT, |
93 | 225 | "--global", | 225 | universal_newlines=True, |
94 | 226 | key | 226 | ).rstrip() |
89 | 227 | ], stderr=subprocess.STDOUT).rstrip() | ||
95 | 228 | except subprocess.CalledProcessError: | 227 | except subprocess.CalledProcessError: |
96 | 229 | current_value = None | 228 | current_value = None |
97 | 230 | 229 | ||
98 | @@ -311,7 +310,7 @@ | |||
99 | 311 | "unity8", | 310 | "unity8", |
100 | 312 | binary_arg, | 311 | binary_arg, |
101 | 313 | extra_args, | 312 | extra_args, |
103 | 314 | ] + ["%s=%s" % (k, v) for k, v in self._environment.iteritems()], | 313 | ] + ["%s=%s" % (k, v) for k, v in self._environment.items()], |
104 | 315 | stderr=subprocess.STDOUT, | 314 | stderr=subprocess.STDOUT, |
105 | 316 | ) | 315 | ) |
106 | 317 | 316 | ||
107 | 318 | 317 | ||
108 | === modified file 'tests/autopilot/unity8/shell/tests/test_lock_screen.py' | |||
109 | --- tests/autopilot/unity8/shell/tests/test_lock_screen.py 2013-08-23 07:38:56 +0000 | |||
110 | +++ tests/autopilot/unity8/shell/tests/test_lock_screen.py 2013-11-19 19:38:26 +0000 | |||
111 | @@ -25,12 +25,18 @@ | |||
112 | 25 | 25 | ||
113 | 26 | from autopilot.matchers import Eventually | 26 | from autopilot.matchers import Eventually |
114 | 27 | from autopilot.platform import model | 27 | from autopilot.platform import model |
115 | 28 | import sys | ||
116 | 28 | from testtools import skipUnless | 29 | from testtools import skipUnless |
117 | 29 | from testtools.matchers import Equals | 30 | from testtools.matchers import Equals |
118 | 30 | import logging | 31 | import logging |
119 | 31 | 32 | ||
120 | 32 | logger = logging.getLogger(__name__) | 33 | logger = logging.getLogger(__name__) |
121 | 33 | 34 | ||
122 | 35 | # py2 compatible alias for py3 | ||
123 | 36 | if sys.version >= '3': | ||
124 | 37 | basestring = str | ||
125 | 38 | |||
126 | 39 | |||
127 | 34 | class TestLockscreen(UnityTestCase): | 40 | class TestLockscreen(UnityTestCase): |
128 | 35 | 41 | ||
129 | 36 | """Tests for the lock screen.""" | 42 | """Tests for the lock screen.""" |
130 | @@ -124,7 +130,10 @@ | |||
131 | 124 | """ | 130 | """ |
132 | 125 | 131 | ||
133 | 126 | if not isinstance(code, basestring): | 132 | if not isinstance(code, basestring): |
135 | 127 | raise TypeError("'code' parameter must be a string.") | 133 | raise TypeError( |
136 | 134 | "'code' parameter must be a string, not %r." | ||
137 | 135 | % type(passphrase) | ||
138 | 136 | ) | ||
139 | 128 | for num in code: | 137 | for num in code: |
140 | 129 | if not num.isdigit(): | 138 | if not num.isdigit(): |
141 | 130 | raise ValueError( | 139 | raise ValueError( |
142 | @@ -141,7 +150,10 @@ | |||
143 | 141 | 150 | ||
144 | 142 | """ | 151 | """ |
145 | 143 | if not isinstance(passphrase, basestring): | 152 | if not isinstance(passphrase, basestring): |
147 | 144 | raise TypeError("'passphrase' parameter must be a string.") | 153 | raise TypeError( |
148 | 154 | "'passphrase' parameter must be a string, not %r." | ||
149 | 155 | % type(passphrase) | ||
150 | 156 | ) | ||
151 | 145 | 157 | ||
152 | 146 | pinentryField = self.main_window.get_pinentryField() | 158 | pinentryField = self.main_window.get_pinentryField() |
153 | 147 | self.touch.tap_object(pinentryField) | 159 | self.touch.tap_object(pinentryField) |
154 | @@ -160,7 +172,10 @@ | |||
155 | 160 | 172 | ||
156 | 161 | """ | 173 | """ |
157 | 162 | if not isinstance(passphrase, basestring): | 174 | if not isinstance(passphrase, basestring): |
159 | 163 | raise TypeError("'passphrase' parameter must be a string.") | 175 | raise TypeError( |
160 | 176 | "'passphrase' parameter must be a string, not %r." | ||
161 | 177 | % type(passphrase) | ||
162 | 178 | ) | ||
163 | 164 | 179 | ||
164 | 165 | prompt = self.main_window.get_greeter().get_prompt() | 180 | prompt = self.main_window.get_greeter().get_prompt() |
165 | 166 | self.touch.tap_object(prompt) | 181 | self.touch.tap_object(prompt) |
166 | 167 | 182 | ||
167 | === modified file 'tests/autopilot/unity8/shell/tests/test_notifications.py' | |||
168 | --- tests/autopilot/unity8/shell/tests/test_notifications.py 2013-11-01 13:59:50 +0000 | |||
169 | +++ tests/autopilot/unity8/shell/tests/test_notifications.py 2013-11-19 19:38:26 +0000 | |||
170 | @@ -32,9 +32,14 @@ | |||
171 | 32 | import logging | 32 | import logging |
172 | 33 | import signal | 33 | import signal |
173 | 34 | import subprocess | 34 | import subprocess |
174 | 35 | import sys | ||
175 | 35 | 36 | ||
176 | 36 | logger = logging.getLogger(__name__) | 37 | logger = logging.getLogger(__name__) |
177 | 37 | 38 | ||
178 | 39 | # backwards compatible alias for Python 3 | ||
179 | 40 | if sys.version > '3': | ||
180 | 41 | xrange = range | ||
181 | 42 | |||
182 | 38 | 43 | ||
183 | 39 | class NotificationsBase(UnityTestCase): | 44 | class NotificationsBase(UnityTestCase): |
184 | 40 | """Base class for all notification tests that provides helper methods.""" | 45 | """Base class for all notification tests that provides helper methods.""" |
185 | @@ -266,6 +271,7 @@ | |||
186 | 266 | stdout=subprocess.PIPE, | 271 | stdout=subprocess.PIPE, |
187 | 267 | stderr=subprocess.PIPE, | 272 | stderr=subprocess.PIPE, |
188 | 268 | close_fds=True, | 273 | close_fds=True, |
189 | 274 | universal_newlines=True, | ||
190 | 269 | ) | 275 | ) |
191 | 270 | 276 | ||
192 | 271 | self.addCleanup(self._tidy_up_script_process) | 277 | self.addCleanup(self._tidy_up_script_process) |
61 - data_path = "/usr/share/ unity8/ mocks/data" share/unity8/ mocks/data"
62 + data_path = u"/usr/
Why are these kinds of changes necessary? "foo" is already a string in Python 3, and Python 2 mostly doesn't care (and obviously the tests currently work with intermixing bytes and strings). The u"" form is deprecated in Python 3, and in fact got removed entirely in 3.0 to 3.2 before it was reintroduced in 3.3 for backwards compat support.
145 - if not isinstance(code, basestring):
147 + if not isinstance(code, str):
Is there a chance that you'll get an unicode object in the tests when running with Python 2? I suppose you ran the py2 tests with this branch and it worked, but just making double-sure.
LGTM otherwise, thanks!