Merge lp:~brian.curtin/ubuntu-sso-client/py3-unicode-part-3 into lp:ubuntu-sso-client
- py3-unicode-part-3
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Alejandro J. Cura |
Approved revision: | 993 |
Merged at revision: | 993 |
Proposed branch: | lp:~brian.curtin/ubuntu-sso-client/py3-unicode-part-3 |
Merge into: | lp:ubuntu-sso-client |
Prerequisite: | lp:~brian.curtin/ubuntu-sso-client/remove-SyncTimestampChecker |
Diff against target: |
813 lines (+144/-107) 17 files modified
ubuntu_sso/qt/tests/show_gui.py (+7/-5) ubuntu_sso/qt/tests/test_common.py (+28/-25) ubuntu_sso/qt/tests/test_current_user_sign_in_page.py (+15/-9) ubuntu_sso/qt/tests/test_forgotten_password.py (+8/-5) ubuntu_sso/qt/tests/test_reset_password.py (+6/-4) ubuntu_sso/qt/tests/test_setup_account.py (+14/-11) ubuntu_sso/qt/tests/test_ssl_dialog.py (+10/-8) ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py (+2/-1) ubuntu_sso/tests/__init__.py (+19/-17) ubuntu_sso/tests/test_account.py (+3/-2) ubuntu_sso/utils/__init__.py (+5/-3) ubuntu_sso/utils/runner/glib.py (+4/-3) ubuntu_sso/utils/runner/tests/test_qt.py (+2/-2) ubuntu_sso/utils/runner/tests/test_runner.py (+5/-3) ubuntu_sso/utils/runner/tx.py (+4/-3) ubuntu_sso/utils/tests/test_common.py (+7/-5) ubuntu_sso/utils/ui.py (+5/-1) |
To merge this branch: | bzr merge lp:~brian.curtin/ubuntu-sso-client/py3-unicode-part-3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Eric Casteleijn (community) | Approve | ||
Alejandro J. Cura (community) | Approve | ||
Review via email: mp+119586@code.launchpad.net |
This proposal supersedes a proposal from 2012-07-30.
Commit message
- Prepare codebase for transition to Python 3 with respect to Unicode usage
Description of the change
The third of three branches to complete the transition to a Unicode-safe Python 2 and Python 3 codebase.
Brian Curtin (brian.curtin) wrote : Posted in a previous version of this proposal | # |
Alejandro J. Cura (alecu) wrote : Posted in a previous version of this proposal | # |
I get a failure when merging this branch with trunk to do the review:
conflicts:
Text conflict in ubuntu_
----
After manually fixing that, all tests pass, but lint complains:
ubuntu_
38: [C0103] Invalid name "install_kwargs" (should match (([A-Z_
----
Please resubmit this proposal (via the link at the top of the page) , having lp:~brian.curtin/ubuntu-sso-client/remove-SyncTimestampChecker as the prerequisite branch.
----
The code looks very good otherwise, and all tests pass.
Great branch!
Brian Curtin (brian.curtin) wrote : | # |
This MP should now cover the three things Alejandro mentioned. Resubmitted MP with prereq branch, merged with trunk, fixed lint warning.
- 991. By Brian Curtin
-
- Remove SyncTimestampCh
ecker as it is no longer used.
Alejandro J. Cura (alecu) wrote : | # |
There are still merge conflicts here:
600 +<<<<<<< TREE
601 +from __future__ import unicode_literals
602 +
603 +import cgi
604 +=======
605 +>>>>>>> MERGE-SOURCE
- 992. By Brian Curtin
- 993. By Brian Curtin
-
Fix merge mishaps, yet again
Eric Casteleijn (thisfred) wrote : | # |
Looks good to me, though I wonder why a lot of the indentation is 8 spaces instead of 4.
Preview Diff
1 | === modified file 'ubuntu_sso/qt/tests/show_gui.py' |
2 | --- ubuntu_sso/qt/tests/show_gui.py 2012-06-27 19:03:44 +0000 |
3 | +++ ubuntu_sso/qt/tests/show_gui.py 2012-08-14 23:18:19 +0000 |
4 | @@ -28,6 +28,8 @@ |
5 | # files in the program, then also delete it here. |
6 | """Script that shows the qt gui.""" |
7 | |
8 | +from __future__ import unicode_literals |
9 | + |
10 | import sys |
11 | |
12 | # pylint: disable=E1101,F0401,E0611 |
13 | @@ -65,12 +67,12 @@ |
14 | client.cred_manager.connect_to_signal('AuthorizationDenied', found) |
15 | client.cred_manager.connect_to_signal('CredentialsError', found) |
16 | |
17 | - yield client.cred_manager.login(u'Ubuntu Two', |
18 | + yield client.cred_manager.login('Ubuntu Two', |
19 | { |
20 | - HELP_TEXT_KEY: u'This is a test help text.', |
21 | - PING_URL_KEY: u'http://www.wikipedia.com/', |
22 | - POLICY_URL_KEY: u'http://one.ubuntu.com/', |
23 | - TC_URL_KEY: u'http://www.google.com/', |
24 | + HELP_TEXT_KEY: 'This is a test help text.', |
25 | + PING_URL_KEY: 'http://www.wikipedia.com/', |
26 | + POLICY_URL_KEY: 'http://one.ubuntu.com/', |
27 | + TC_URL_KEY: 'http://www.google.com/', |
28 | }) |
29 | yield d |
30 | |
31 | |
32 | === modified file 'ubuntu_sso/qt/tests/test_common.py' |
33 | --- ubuntu_sso/qt/tests/test_common.py 2012-06-22 20:52:26 +0000 |
34 | +++ ubuntu_sso/qt/tests/test_common.py 2012-08-14 23:18:19 +0000 |
35 | @@ -29,10 +29,13 @@ |
36 | # files in the program, then also delete it here. |
37 | """Test the common functions.""" |
38 | |
39 | +from __future__ import unicode_literals |
40 | + |
41 | from PyQt4 import QtGui |
42 | from twisted.internet import defer |
43 | from twisted.trial.unittest import TestCase |
44 | |
45 | +from ubuntu_sso.utils import compat |
46 | from ubuntu_sso.qt import ( |
47 | build_general_error_message, |
48 | maybe_elide_text, |
49 | @@ -74,7 +77,7 @@ |
50 | password_assistance(self.line_edit, self.label_assistance) |
51 | self.assertIn( |
52 | BAD % PASSWORD_LENGTH, |
53 | - unicode(self.label_assistance.text()), |
54 | + compat.text_type(self.label_assistance.text()), |
55 | ) |
56 | |
57 | def test_long_password(self): |
58 | @@ -86,7 +89,7 @@ |
59 | password_assistance(self.line_edit, self.label_assistance) |
60 | self.assertIn( |
61 | GOOD % PASSWORD_LENGTH, |
62 | - unicode(self.label_assistance.text()), |
63 | + compat.text_type(self.label_assistance.text()), |
64 | ) |
65 | |
66 | def test_no_number_password(self): |
67 | @@ -98,7 +101,7 @@ |
68 | password_assistance(self.line_edit, self.label_assistance) |
69 | self.assertIn( |
70 | BAD % PASSWORD_DIGIT, |
71 | - unicode(self.label_assistance.text()), |
72 | + compat.text_type(self.label_assistance.text()), |
73 | ) |
74 | |
75 | def test_number_password(self): |
76 | @@ -110,7 +113,7 @@ |
77 | password_assistance(self.line_edit, self.label_assistance) |
78 | self.assertIn( |
79 | GOOD % PASSWORD_DIGIT, |
80 | - unicode(self.label_assistance.text()), |
81 | + compat.text_type(self.label_assistance.text()), |
82 | ) |
83 | |
84 | def test_no_uppercase_password(self): |
85 | @@ -122,7 +125,7 @@ |
86 | password_assistance(self.line_edit, self.label_assistance) |
87 | self.assertIn( |
88 | BAD % PASSWORD_UPPER, |
89 | - unicode(self.label_assistance.text()), |
90 | + compat.text_type(self.label_assistance.text()), |
91 | ) |
92 | |
93 | def test_upper_password(self): |
94 | @@ -134,7 +137,7 @@ |
95 | password_assistance(self.line_edit, self.label_assistance) |
96 | self.assertIn( |
97 | GOOD % PASSWORD_UPPER, |
98 | - unicode(self.label_assistance.text()), |
99 | + compat.text_type(self.label_assistance.text()), |
100 | ) |
101 | |
102 | def test_matching_passwords(self): |
103 | @@ -148,7 +151,7 @@ |
104 | self.line_edit_confirm, self.label_assistance) |
105 | self.assertNotIn( |
106 | BAD % PASSWORD_MATCH, |
107 | - unicode(self.label_assistance.text())) |
108 | + compat.text_type(self.label_assistance.text())) |
109 | |
110 | def test_not_matching_passwords(self): |
111 | """Status when the passwords not match. |
112 | @@ -161,7 +164,7 @@ |
113 | self.line_edit_confirm, self.label_assistance) |
114 | self.assertIn( |
115 | BAD % PASSWORD_MATCH, |
116 | - unicode(self.label_assistance.text()), |
117 | + compat.text_type(self.label_assistance.text()), |
118 | ) |
119 | |
120 | def test_password_assistance_in_focus_length_correct(self): |
121 | @@ -171,15 +174,15 @@ |
122 | password_assistance(self.line_edit, self.label_assistance, NORMAL) |
123 | self.assertIn( |
124 | GOOD % PASSWORD_LENGTH, |
125 | - unicode(self.label_assistance.text()), |
126 | + compat.text_type(self.label_assistance.text()), |
127 | ) |
128 | self.assertIn( |
129 | NORMAL % PASSWORD_UPPER, |
130 | - unicode(self.label_assistance.text()), |
131 | + compat.text_type(self.label_assistance.text()), |
132 | ) |
133 | self.assertIn( |
134 | NORMAL % PASSWORD_DIGIT, |
135 | - unicode(self.label_assistance.text()), |
136 | + compat.text_type(self.label_assistance.text()), |
137 | ) |
138 | |
139 | def test_password_assistance_in_focus_with_upper(self): |
140 | @@ -189,15 +192,15 @@ |
141 | password_assistance(self.line_edit, self.label_assistance, NORMAL) |
142 | self.assertIn( |
143 | NORMAL % PASSWORD_LENGTH, |
144 | - unicode(self.label_assistance.text()), |
145 | + compat.text_type(self.label_assistance.text()), |
146 | ) |
147 | self.assertIn( |
148 | GOOD % PASSWORD_UPPER, |
149 | - unicode(self.label_assistance.text()), |
150 | + compat.text_type(self.label_assistance.text()), |
151 | ) |
152 | self.assertIn( |
153 | NORMAL % PASSWORD_DIGIT, |
154 | - unicode(self.label_assistance.text()), |
155 | + compat.text_type(self.label_assistance.text()), |
156 | ) |
157 | |
158 | def test_password_assistance_in_focus_with_number(self): |
159 | @@ -207,15 +210,15 @@ |
160 | password_assistance(self.line_edit, self.label_assistance, NORMAL) |
161 | self.assertIn( |
162 | NORMAL % PASSWORD_LENGTH, |
163 | - unicode(self.label_assistance.text()), |
164 | + compat.text_type(self.label_assistance.text()), |
165 | ) |
166 | self.assertIn( |
167 | NORMAL % PASSWORD_UPPER, |
168 | - unicode(self.label_assistance.text()), |
169 | + compat.text_type(self.label_assistance.text()), |
170 | ) |
171 | self.assertIn( |
172 | GOOD % PASSWORD_DIGIT, |
173 | - unicode(self.label_assistance.text()), |
174 | + compat.text_type(self.label_assistance.text()), |
175 | ) |
176 | |
177 | def test_password_assistance_in_focus_all_ok(self): |
178 | @@ -225,19 +228,19 @@ |
179 | password_assistance(self.line_edit, self.label_assistance, NORMAL) |
180 | self.assertIn( |
181 | GOOD % PASSWORD_LENGTH, |
182 | - unicode(self.label_assistance.text()), |
183 | + compat.text_type(self.label_assistance.text()), |
184 | ) |
185 | self.assertIn( |
186 | GOOD % PASSWORD_UPPER, |
187 | - unicode(self.label_assistance.text()), |
188 | + compat.text_type(self.label_assistance.text()), |
189 | ) |
190 | self.assertIn( |
191 | GOOD % PASSWORD_DIGIT, |
192 | - unicode(self.label_assistance.text()), |
193 | + compat.text_type(self.label_assistance.text()), |
194 | ) |
195 | self.assertNotIn( |
196 | NORMAL % PASSWORD_MATCH, |
197 | - unicode(self.label_assistance.text()), |
198 | + compat.text_type(self.label_assistance.text()), |
199 | ) |
200 | |
201 | |
202 | @@ -276,7 +279,7 @@ |
203 | |
204 | self.assertEqual(self.ui.toolTip(), '') |
205 | self.assertEqual(self.ui.text(), text) |
206 | - self.assertNotIn(u'\u2026', self.ui.text()) |
207 | + self.assertNotIn('\u2026', self.ui.text()) |
208 | |
209 | def test_text_not_elided_if_equals_max_width(self): |
210 | """If text is equal than max_width, do not elide.""" |
211 | @@ -286,7 +289,7 @@ |
212 | |
213 | self.assertEqual(self.ui.toolTip(), '') |
214 | self.assertEqual(self.ui.text(), text) |
215 | - self.assertNotIn(u'\u2026', self.ui.text()) |
216 | + self.assertNotIn('\u2026', self.ui.text()) |
217 | |
218 | def test_text_elided_if_bigger_than_max_width(self): |
219 | """If text is equal than max_width, do not elide.""" |
220 | @@ -295,8 +298,8 @@ |
221 | maybe_elide_text(self.ui, text, self.max_width) |
222 | |
223 | self.assertEqual(self.ui.toolTip(), text) |
224 | - expected = unicode(self.ui.text()) |
225 | - self.assertTrue(expected.endswith(u'\u2026')) |
226 | + expected = compat.text_type(self.ui.text()) |
227 | + self.assertTrue(expected.endswith('\u2026')) |
228 | self.assertTrue(text.startswith(expected[:-1])) |
229 | |
230 | |
231 | |
232 | === modified file 'ubuntu_sso/qt/tests/test_current_user_sign_in_page.py' |
233 | --- ubuntu_sso/qt/tests/test_current_user_sign_in_page.py 2012-06-08 15:10:34 +0000 |
234 | +++ ubuntu_sso/qt/tests/test_current_user_sign_in_page.py 2012-08-14 23:18:19 +0000 |
235 | @@ -28,8 +28,11 @@ |
236 | # files in the program, then also delete it here. |
237 | """Tests for the Setup Account page Qt UI.""" |
238 | |
239 | +from __future__ import unicode_literals |
240 | + |
241 | from PyQt4 import QtGui, QtCore |
242 | |
243 | +from ubuntu_sso.utils import compat |
244 | from ubuntu_sso.qt import current_user_sign_in_page as gui |
245 | from ubuntu_sso.qt.tests import ( |
246 | PageBaseTestCase, |
247 | @@ -66,13 +69,14 @@ |
248 | |
249 | def test_unicode_in_forgotten_password_link(self): |
250 | """Ensure that this label supports unicode.""" |
251 | - forgot_fr = u"J'ai oublié mon mot de passe" |
252 | + forgot_fr = "J'ai oublié mon mot de passe" |
253 | self.patch(gui, "FORGOTTEN_PASSWORD_BUTTON", forgot_fr) |
254 | forgotten_text = gui.LINK_STYLE.format(link_url='#', |
255 | link_text=forgot_fr) |
256 | self.ui._set_translated_strings() |
257 | - self.assertEqual(unicode(self.ui.ui.forgot_password_label.text()), |
258 | - forgotten_text) |
259 | + self.assertEqual( |
260 | + compat.text_type(self.ui.ui.forgot_password_label.text()), |
261 | + forgotten_text) |
262 | |
263 | def test_set_translated_strings(self): |
264 | """Test the translated string method.""" |
265 | @@ -80,16 +84,18 @@ |
266 | self.assert_title_correct(expected) |
267 | expected = gui.LOGIN_SUBTITLE % dict(app_name=self.app_name) |
268 | self.assert_subtitle_correct(expected) |
269 | - self.assertEqual(unicode(self.ui.ui.email_label.text()), |
270 | + self.assertEqual(compat.text_type(self.ui.ui.email_label.text()), |
271 | gui.EMAIL_LABEL) |
272 | - self.assertEqual(unicode(self.ui.ui.password_label.text()), |
273 | + self.assertEqual(compat.text_type(self.ui.ui.password_label.text()), |
274 | gui.LOGIN_PASSWORD_LABEL) |
275 | text = gui.LINK_STYLE.format(link_url='#', |
276 | link_text=gui.FORGOTTEN_PASSWORD_BUTTON) |
277 | - self.assertEqual(unicode(self.ui.ui.forgot_password_label.text()), |
278 | - text) |
279 | - self.assertEqual(unicode(self.ui.ui.sign_in_button.text()), |
280 | - gui.SIGN_IN_BUTTON) |
281 | + self.assertEqual( |
282 | + compat.text_type(self.ui.ui.forgot_password_label.text()), |
283 | + text) |
284 | + self.assertEqual( |
285 | + compat.text_type(self.ui.ui.sign_in_button.text()), |
286 | + gui.SIGN_IN_BUTTON) |
287 | |
288 | def test_connect_ui(self): |
289 | """Test the connect ui method.""" |
290 | |
291 | === modified file 'ubuntu_sso/qt/tests/test_forgotten_password.py' |
292 | --- ubuntu_sso/qt/tests/test_forgotten_password.py 2012-04-09 17:38:24 +0000 |
293 | +++ ubuntu_sso/qt/tests/test_forgotten_password.py 2012-08-14 23:18:19 +0000 |
294 | @@ -30,6 +30,7 @@ |
295 | |
296 | from PyQt4 import QtCore |
297 | |
298 | +from ubuntu_sso.utils import compat |
299 | from ubuntu_sso.qt import forgotten_password_page as gui |
300 | from ubuntu_sso.qt.tests import ( |
301 | PageBaseTestCase, |
302 | @@ -60,8 +61,9 @@ |
303 | def test_email_address(self): |
304 | """Test the email_address property.""" |
305 | value = self.ui.email_address |
306 | - self.assertEqual(value, unicode(self.ui.ui.email_line_edit.text())) |
307 | - self.assertTrue(isinstance(value, unicode)) |
308 | + self.assertEqual(value, |
309 | + compat.text_type(self.ui.ui.email_line_edit.text())) |
310 | + self.assertTrue(isinstance(value, compat.text_type)) |
311 | |
312 | def test_send_button_clicked(self): |
313 | """Test the send_button property.""" |
314 | @@ -87,9 +89,10 @@ |
315 | subtitle = gui.FORGOTTEN_PASSWORD_SUBTITLE |
316 | self.assert_subtitle_correct(subtitle.format(app_name=self.app_name)) |
317 | |
318 | - self.assertEqual(unicode(self.ui.ui.email_address_label.text()), |
319 | - gui.EMAIL_LABEL) |
320 | - self.assertEqual(unicode(self.ui.ui.send_button.text()), |
321 | + self.assertEqual( |
322 | + compat.text_type(self.ui.ui.email_address_label.text()), |
323 | + gui.EMAIL_LABEL) |
324 | + self.assertEqual(compat.text_type(self.ui.ui.send_button.text()), |
325 | gui.RESET_PASSWORD) |
326 | |
327 | def test_connect_ui(self): |
328 | |
329 | === modified file 'ubuntu_sso/qt/tests/test_reset_password.py' |
330 | --- ubuntu_sso/qt/tests/test_reset_password.py 2012-04-09 17:38:24 +0000 |
331 | +++ ubuntu_sso/qt/tests/test_reset_password.py 2012-08-14 23:18:19 +0000 |
332 | @@ -32,6 +32,7 @@ |
333 | |
334 | from PyQt4 import QtGui, QtCore |
335 | |
336 | +from ubuntu_sso.utils import compat |
337 | from ubuntu_sso.utils.ui import ( |
338 | PASSWORD1_ENTRY, |
339 | PASSWORD2_ENTRY, |
340 | @@ -86,11 +87,12 @@ |
341 | self.ui.initializePage() |
342 | self.assert_title_correct(RESET_TITLE) |
343 | self.assert_subtitle_correct(RESET_SUBTITLE) |
344 | - self.assertEqual(unicode(self.ui.ui.password_label.text()), |
345 | + self.assertEqual(compat.text_type(self.ui.ui.password_label.text()), |
346 | PASSWORD1_ENTRY) |
347 | - self.assertEqual(unicode(self.ui.ui.confirm_password_label.text()), |
348 | - PASSWORD2_ENTRY) |
349 | - self.assertEqual(unicode(self.ui.ui.reset_code.text()), |
350 | + self.assertEqual( |
351 | + compat.text_type(self.ui.ui.confirm_password_label.text()), |
352 | + PASSWORD2_ENTRY) |
353 | + self.assertEqual(compat.text_type(self.ui.ui.reset_code.text()), |
354 | RESET_CODE_ENTRY) |
355 | |
356 | def test_focus_changed_password_visibility(self): |
357 | |
358 | === modified file 'ubuntu_sso/qt/tests/test_setup_account.py' |
359 | --- ubuntu_sso/qt/tests/test_setup_account.py 2012-07-31 20:56:16 +0000 |
360 | +++ ubuntu_sso/qt/tests/test_setup_account.py 2012-08-14 23:18:19 +0000 |
361 | @@ -30,6 +30,7 @@ |
362 | |
363 | from PyQt4 import QtGui, QtCore |
364 | |
365 | +from ubuntu_sso.utils import compat |
366 | from ubuntu_sso.tests import CAPTCHA_PATH |
367 | |
368 | from ubuntu_sso.qt import common, setup_account_page as gui |
369 | @@ -69,7 +70,7 @@ |
370 | |
371 | self.ui.ui.refresh_label.linkActivated.emit('error') |
372 | |
373 | - message = unicode(self.ui.form_errors_label.text()) |
374 | + message = compat.text_type(self.ui.form_errors_label.text()) |
375 | self.assertEqual(message, ' ') |
376 | |
377 | def test_enable_setup_button_with_visible_check(self): |
378 | @@ -118,15 +119,15 @@ |
379 | self.ui.focus_changed(None, self.ui.ui.password_edit) |
380 | self.assertIn( |
381 | common.NORMAL % common.PASSWORD_LENGTH, |
382 | - unicode(self.ui.ui.password_assistance.text()), |
383 | + compat.text_type(self.ui.ui.password_assistance.text()), |
384 | ) |
385 | self.assertIn( |
386 | common.NORMAL % common.PASSWORD_UPPER, |
387 | - unicode(self.ui.ui.password_assistance.text()), |
388 | + compat.text_type(self.ui.ui.password_assistance.text()), |
389 | ) |
390 | self.assertIn( |
391 | common.NORMAL % common.PASSWORD_DIGIT, |
392 | - unicode(self.ui.ui.password_assistance.text()), |
393 | + compat.text_type(self.ui.ui.password_assistance.text()), |
394 | ) |
395 | |
396 | def test_password_focus_gain(self): |
397 | @@ -221,16 +222,18 @@ |
398 | self.assertFalse(self.ui.captcha_received) |
399 | |
400 | # labels |
401 | - self.assertEqual(unicode(self.ui.ui.name_label.text()), |
402 | + self.assertEqual(compat.text_type(self.ui.ui.name_label.text()), |
403 | gui.NAME_ENTRY) |
404 | - self.assertEqual(unicode(self.ui.ui.email_label.text()), |
405 | + self.assertEqual(compat.text_type(self.ui.ui.email_label.text()), |
406 | gui.EMAIL) |
407 | - self.assertEqual(unicode(self.ui.ui.confirm_email_label.text()), |
408 | - gui.RETYPE_EMAIL) |
409 | - self.assertEqual(unicode(self.ui.ui.password_label.text()), |
410 | + self.assertEqual( |
411 | + compat.text_type(self.ui.ui.confirm_email_label.text()), |
412 | + gui.RETYPE_EMAIL) |
413 | + self.assertEqual(compat.text_type(self.ui.ui.password_label.text()), |
414 | gui.PASSWORD) |
415 | - self.assertEqual(unicode(self.ui.ui.confirm_password_label.text()), |
416 | - gui.RETYPE_PASSWORD) |
417 | + self.assertEqual( |
418 | + compat.text_type(self.ui.ui.confirm_password_label.text()), |
419 | + gui.RETYPE_PASSWORD) |
420 | |
421 | # assistants |
422 | self.assertFalse(self.ui.ui.name_assistance.isVisible()) |
423 | |
424 | === modified file 'ubuntu_sso/qt/tests/test_ssl_dialog.py' |
425 | --- ubuntu_sso/qt/tests/test_ssl_dialog.py 2012-04-09 17:38:24 +0000 |
426 | +++ ubuntu_sso/qt/tests/test_ssl_dialog.py 2012-08-14 23:18:19 +0000 |
427 | @@ -34,6 +34,7 @@ |
428 | |
429 | from ubuntu_sso import USER_CANCELLATION, USER_SUCCESS |
430 | from ubuntu_sso.qt import ssl_dialog |
431 | +from ubuntu_sso.utils import compat |
432 | from ubuntu_sso.utils.ui import ( |
433 | CANCEL_BUTTON, |
434 | SSL_APPNAME_HELP, |
435 | @@ -94,17 +95,18 @@ |
436 | def test_set_labels(self): |
437 | """Test that the labels contain the correct info.""" |
438 | self.assertEqual(SSL_HEADER, |
439 | - unicode(self.dialog.ui.title_label.text())) |
440 | + compat.text_type(self.dialog.ui.title_label.text())) |
441 | explanation = SSL_EXPLANATION % dict(domain=self.domain) |
442 | intro = ssl_dialog.REASONS_TEMPLATE % dict(explanation=explanation, |
443 | first_reason=SSL_FIRST_REASON, |
444 | second_reason=SSL_SECOND_REASON, |
445 | third_reason=SSL_THIRD_REASON) |
446 | - self.assertEqual(intro, unicode(self.dialog.ui.intro_label.text())) |
447 | + self.assertEqual(intro, |
448 | + compat.text_type(self.dialog.ui.intro_label.text())) |
449 | self.assertEqual(SSL_NOT_SURE % dict(app_name=self.appname), |
450 | - unicode(self.dialog.ui.not_sure_label.text())) |
451 | + compat.text_type(self.dialog.ui.not_sure_label.text())) |
452 | self.assertEqual(SSL_REMEMBER_DECISION, |
453 | - unicode(self.dialog.ui.remember_checkbox.text())) |
454 | + compat.text_type(self.dialog.ui.remember_checkbox.text())) |
455 | |
456 | def test_on_cancel_clicked(self): |
457 | """Test the cancelation action.""" |
458 | @@ -146,16 +148,16 @@ |
459 | self.assertIn('_on_cancel_clicked', called) |
460 | |
461 | self.assertEqual(CANCEL_BUTTON, |
462 | - unicode(dialog.ui.cancel_button.text())) |
463 | + compat.text_type(dialog.ui.cancel_button.text())) |
464 | self.assertEqual(SSL_CONNECT_BUTTON, |
465 | - unicode(dialog.ui.connect_button.text())) |
466 | + compat.text_type(dialog.ui.connect_button.text())) |
467 | self.assertEqual(SSL_HELP_BUTTON, |
468 | - unicode(dialog.ui.help_button.text())) |
469 | + compat.text_type(dialog.ui.help_button.text())) |
470 | |
471 | def test_set_expander(self): |
472 | """Test that the expander is correctly set.""" |
473 | self.assertEqual(SSL_CERT_DETAILS, |
474 | - unicode(self.dialog.expander.text())) |
475 | + compat.text_type(self.dialog.expander.text())) |
476 | self.assertNotEqual(None, self.dialog.expander.content) |
477 | self.assertEqual(2, self.dialog.ui.expander_layout.indexOf( |
478 | self.dialog.expander)) |
479 | |
480 | === modified file 'ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py' |
481 | --- ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py 2012-05-11 18:32:40 +0000 |
482 | +++ ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py 2012-08-14 23:18:19 +0000 |
483 | @@ -41,6 +41,7 @@ |
484 | BaseTestCase, |
485 | FakeOverlay, |
486 | ) |
487 | +from ubuntu_sso.utils import compat |
488 | |
489 | |
490 | # is ok to access private method/attrs in tests |
491 | @@ -107,7 +108,7 @@ |
492 | |
493 | def test_window_title(self): |
494 | """Check the window title for the application.""" |
495 | - title = unicode(self.ui.windowTitle()) |
496 | + title = compat.text_type(self.ui.windowTitle()) |
497 | self.assertEqual(title, ubuntu_sso_wizard.WINDOW_TITLE) |
498 | |
499 | |
500 | |
501 | === modified file 'ubuntu_sso/tests/__init__.py' |
502 | --- ubuntu_sso/tests/__init__.py 2012-06-27 19:03:44 +0000 |
503 | +++ ubuntu_sso/tests/__init__.py 2012-08-14 23:18:19 +0000 |
504 | @@ -28,6 +28,8 @@ |
505 | # files in the program, then also delete it here. |
506 | """Tests for the Ubuntu SSO library.""" |
507 | |
508 | +from __future__ import unicode_literals |
509 | + |
510 | import os |
511 | |
512 | from collections import defaultdict |
513 | @@ -38,30 +40,30 @@ |
514 | |
515 | from ubuntu_sso.keyring import get_token_name |
516 | |
517 | -APP_NAME = u'I ♥ Ubuntu' |
518 | -CAPTCHA_ID = u'test ñiña' |
519 | +APP_NAME = 'I ♥ Ubuntu' |
520 | +CAPTCHA_ID = 'test ñiña' |
521 | CAPTCHA_PATH = os.path.abspath(os.path.join(os.curdir, 'ubuntu_sso', 'tests', |
522 | 'files', 'captcha.png')) |
523 | -CAPTCHA_SOLUTION = u'william Byrd ñandú' |
524 | -EMAIL = u'test@example.com' |
525 | -EMAIL_TOKEN = u'B2P☺ gtf' |
526 | +CAPTCHA_SOLUTION = 'william Byrd ñandú' |
527 | +EMAIL = 'test@example.com' |
528 | +EMAIL_TOKEN = 'B2P☺ gtf' |
529 | GUI_EXE = 'ubuntu-sso-login-qt' |
530 | -HELP_TEXT = u'☛ Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \ |
531 | +HELP_TEXT = '☛ Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \ |
532 | 'Nam sed lorem nibh. Suspendisse gravida nulla non nunc suscipit pulvinar ' \ |
533 | 'tempus ut augue. Morbi consequat, ligula a elementum pretium, ' \ |
534 | 'dolor nulla tempus metus, sed viverra nisi risus non velit.' |
535 | -NAME = u'Juanito ☀ Pérez' |
536 | -PASSWORD = u'h3lloWorld☑ ' |
537 | -PING_URL = u'http://localhost/ping-me/' |
538 | -POLICY_URL = u'http://localhost/policy/' |
539 | -RESET_PASSWORD_TOKEN = u'8G5Wtq' |
540 | -TOKEN = {u'consumer_key': u'xQ7xDAz', |
541 | - u'consumer_secret': u'KzCJWCTNbbntwfyCKKjomJDzlgqxLy', |
542 | - u'token_name': u'test', |
543 | - u'token': u'GkInOfSMGwTXAUoVQwLUoPxElEEUdhsLVNTPhxHJDUIeHCPNEo', |
544 | - u'token_secret': u'qFYImEtlczPbsCnYyuwLoPDlPEnvNcIktZphPQklAWrvyfFMV'} |
545 | +NAME = 'Juanito ☀ Pérez' |
546 | +PASSWORD = 'h3lloWorld☑ ' |
547 | +PING_URL = 'http://localhost/ping-me/' |
548 | +POLICY_URL = 'http://localhost/policy/' |
549 | +RESET_PASSWORD_TOKEN = '8G5Wtq' |
550 | +TOKEN = {'consumer_key': 'xQ7xDAz', |
551 | + 'consumer_secret': 'KzCJWCTNbbntwfyCKKjomJDzlgqxLy', |
552 | + 'token_name': 'test', |
553 | + 'token': 'GkInOfSMGwTXAUoVQwLUoPxElEEUdhsLVNTPhxHJDUIeHCPNEo', |
554 | + 'token_secret': 'qFYImEtlczPbsCnYyuwLoPDlPEnvNcIktZphPQklAWrvyfFMV'} |
555 | TOKEN_NAME = get_token_name(APP_NAME) |
556 | -TC_URL = u'http://localhost/' |
557 | +TC_URL = 'http://localhost/' |
558 | WINDOW_ID = 5 |
559 | |
560 | |
561 | |
562 | === modified file 'ubuntu_sso/tests/test_account.py' |
563 | --- ubuntu_sso/tests/test_account.py 2012-08-14 16:23:35 +0000 |
564 | +++ ubuntu_sso/tests/test_account.py 2012-08-14 23:18:19 +0000 |
565 | @@ -72,6 +72,7 @@ |
566 | TOKEN, |
567 | TOKEN_NAME, |
568 | ) |
569 | +from ubuntu_sso.utils import compat |
570 | |
571 | |
572 | CANT_RESET_PASSWORD_CONTENT = "CanNotResetPassowrdError: " \ |
573 | @@ -87,7 +88,7 @@ |
574 | STATUS_EMAIL_OK = {'email': EMAIL} |
575 | |
576 | FAKE_NEW_CAPTCHA = { |
577 | - 'image_url': "file://" + unicode(CAPTCHA_PATH), |
578 | + 'image_url': "file://" + compat.text_type(CAPTCHA_PATH), |
579 | 'captcha_id': CAPTCHA_ID, |
580 | } |
581 | |
582 | @@ -195,7 +196,7 @@ |
583 | def check_all_kwargs_unicode(self, **kwargs): |
584 | """Check that the values of all keyword arguments are unicode.""" |
585 | for (key, value) in kwargs.items(): |
586 | - if isinstance(value, str): |
587 | + if isinstance(value, compat.binary_type): |
588 | raise AssertionError("Error: kwarg '%s' is non-unicode." % key) |
589 | |
590 | def restcall(self, method_name, **kwargs): |
591 | |
592 | === modified file 'ubuntu_sso/utils/__init__.py' |
593 | --- ubuntu_sso/utils/__init__.py 2012-08-09 15:59:14 +0000 |
594 | +++ ubuntu_sso/utils/__init__.py 2012-08-14 23:18:19 +0000 |
595 | @@ -28,6 +28,8 @@ |
596 | # files in the program, then also delete it here. |
597 | """Utility modules that may find use outside ubuntu_sso.""" |
598 | |
599 | +from __future__ import unicode_literals |
600 | + |
601 | import os |
602 | import sys |
603 | |
604 | @@ -40,7 +42,7 @@ |
605 | UI_PROXY_CREDS_DIALOG, |
606 | UI_SSL_DIALOG) |
607 | from ubuntu_sso.logger import setup_logging |
608 | -from ubuntu_sso.utils import webclient |
609 | +from ubuntu_sso.utils import compat, webclient |
610 | |
611 | |
612 | logger = setup_logging("ubuntu_sso.utils") |
613 | @@ -147,7 +149,7 @@ |
614 | """ |
615 | logger.info('Pinging server using url: %r, email: %r.', |
616 | url, email) |
617 | - assert isinstance(url, unicode), 'Url %r must be unicode' % url |
618 | + assert isinstance(url, compat.text_type), 'Url %r must be unicode' % url |
619 | |
620 | target_url = url |
621 | try: |
622 | @@ -158,7 +160,7 @@ |
623 | if target_url == url: |
624 | logger.debug('Original url (%r) could not be formatted, ' |
625 | 'appending email (%r).', url, email) |
626 | - assert url.endswith(u'/'), 'Url %r must end with /.' % url |
627 | + assert url.endswith('/'), 'Url %r must end with /.' % url |
628 | target_url = url + email |
629 | |
630 | wc = webclient.webclient_factory() |
631 | |
632 | === modified file 'ubuntu_sso/utils/runner/glib.py' |
633 | --- ubuntu_sso/utils/runner/glib.py 2012-06-22 16:12:03 +0000 |
634 | +++ ubuntu_sso/utils/runner/glib.py 2012-08-14 23:18:19 +0000 |
635 | @@ -35,6 +35,7 @@ |
636 | # pylint: enable=E0611,F0401 |
637 | |
638 | from ubuntu_sso.logger import setup_logging |
639 | +from ubuntu_sso.utils import compat |
640 | |
641 | logger = setup_logging("ubuntu_sso.utils.runner.glib") |
642 | |
643 | @@ -81,10 +82,10 @@ |
644 | |
645 | bytes_args = [] |
646 | for arg in args: |
647 | - if isinstance(arg, unicode): |
648 | + if isinstance(arg, compat.text_type): |
649 | arg = arg.encode('utf-8') |
650 | - if not isinstance(arg, basestring): |
651 | - arg = str(arg) |
652 | + if not isinstance(arg, compat.basestring): |
653 | + arg = compat.binary_type(arg) |
654 | bytes_args.append(arg) |
655 | |
656 | try: |
657 | |
658 | === modified file 'ubuntu_sso/utils/runner/tests/test_qt.py' |
659 | --- ubuntu_sso/utils/runner/tests/test_qt.py 2012-06-22 16:12:03 +0000 |
660 | +++ ubuntu_sso/utils/runner/tests/test_qt.py 2012-08-14 23:18:19 +0000 |
661 | @@ -33,7 +33,7 @@ |
662 | from PyQt4 import QtCore |
663 | from twisted.internet import defer |
664 | |
665 | -from ubuntu_sso.utils import runner |
666 | +from ubuntu_sso.utils import compat, runner |
667 | from ubuntu_sso.utils.runner import qt |
668 | from ubuntu_sso.utils.runner.tests.test_runner import SpawnProgramTestCase |
669 | |
670 | @@ -80,7 +80,7 @@ |
671 | # subprocess expects bytes |
672 | bytes_args = [] |
673 | for arg in args: |
674 | - if isinstance(arg, unicode): |
675 | + if isinstance(arg, compat.text_type): |
676 | arg = arg.encode('utf-8') |
677 | bytes_args.append(arg) |
678 | |
679 | |
680 | === modified file 'ubuntu_sso/utils/runner/tests/test_runner.py' |
681 | --- ubuntu_sso/utils/runner/tests/test_runner.py 2012-04-09 17:38:24 +0000 |
682 | +++ ubuntu_sso/utils/runner/tests/test_runner.py 2012-08-14 23:18:19 +0000 |
683 | @@ -28,6 +28,8 @@ |
684 | # files in the program, then also delete it here. |
685 | """Tests for the runner helper module.""" |
686 | |
687 | +from __future__ import unicode_literals |
688 | + |
689 | import os |
690 | |
691 | from twisted.internet import defer |
692 | @@ -36,15 +38,15 @@ |
693 | from ubuntu_sso.utils import runner |
694 | |
695 | |
696 | -TEST_ME_DIR = u'test-me-more-♥' |
697 | +TEST_ME_DIR = 'test-me-more-♥' |
698 | TEST_ME_DIR_BYTES = TEST_ME_DIR.encode('utf-8') |
699 | |
700 | |
701 | class SpawnProgramTestCase(TestCase): |
702 | """The test suite for the spawn_program method.""" |
703 | |
704 | - args = (u'python', u'-c', |
705 | - u'import os; os.system("mkdir %s")' % TEST_ME_DIR) |
706 | + args = ('python', '-c', |
707 | + 'import os; os.system("mkdir %s")' % TEST_ME_DIR) |
708 | use_reactor = True |
709 | timeout = 3 |
710 | |
711 | |
712 | === modified file 'ubuntu_sso/utils/runner/tx.py' |
713 | --- ubuntu_sso/utils/runner/tx.py 2012-08-09 18:50:11 +0000 |
714 | +++ ubuntu_sso/utils/runner/tx.py 2012-08-14 23:18:19 +0000 |
715 | @@ -34,6 +34,7 @@ |
716 | from twisted.internet import utils |
717 | |
718 | from ubuntu_sso.logger import setup_logging |
719 | +from ubuntu_sso.utils import compat |
720 | |
721 | |
722 | logger = setup_logging("ubuntu_sso.utils.runner.tx") |
723 | @@ -83,10 +84,10 @@ |
724 | |
725 | bytes_args = [] |
726 | for arg in argv: |
727 | - if isinstance(arg, unicode): |
728 | + if isinstance(arg, compat.text_type): |
729 | arg = arg.encode('utf-8') |
730 | - if not isinstance(arg, basestring): |
731 | - arg = str(arg) |
732 | + if not isinstance(arg, compat.basestring): |
733 | + arg = compat.binary_type(arg) |
734 | bytes_args.append(arg) |
735 | |
736 | if program and not os.access(program, os.X_OK): |
737 | |
738 | === modified file 'ubuntu_sso/utils/tests/test_common.py' |
739 | --- ubuntu_sso/utils/tests/test_common.py 2012-08-08 21:08:22 +0000 |
740 | +++ ubuntu_sso/utils/tests/test_common.py 2012-08-14 23:18:19 +0000 |
741 | @@ -28,6 +28,8 @@ |
742 | # files in the program, then also delete it here. |
743 | """Tests for the oauth_headers helper function.""" |
744 | |
745 | +from __future__ import unicode_literals |
746 | + |
747 | import logging |
748 | import sys |
749 | |
750 | @@ -220,7 +222,7 @@ |
751 | @defer.inlineCallbacks |
752 | def setUp(self): |
753 | yield super(PingUrlTestCase, self).setUp() |
754 | - self.url = u'http://example.com/' |
755 | + self.url = 'http://example.com/' |
756 | self.wc = FakeWebclient() |
757 | self.patch(utils.webclient, "webclient_factory", |
758 | lambda *args: self.wc) |
759 | @@ -251,7 +253,7 @@ |
760 | @defer.inlineCallbacks |
761 | def test_ping_url_formatting(self): |
762 | """The email is added as the first formatting argument.""" |
763 | - self.url = u'http://example.com/{email}/something/else' |
764 | + self.url = 'http://example.com/{email}/something/else' |
765 | yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN) |
766 | |
767 | expected = self.url.format(email=EMAIL) |
768 | @@ -262,7 +264,7 @@ |
769 | @defer.inlineCallbacks |
770 | def test_ping_url_formatting_with_query_params(self): |
771 | """The email is added as the first formatting argument.""" |
772 | - self.url = u'http://example.com/{email}?something=else' |
773 | + self.url = 'http://example.com/{email}?something=else' |
774 | yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN) |
775 | |
776 | expected = self.url.format(email=EMAIL) |
777 | @@ -273,7 +275,7 @@ |
778 | @defer.inlineCallbacks |
779 | def test_ping_url_formatting_no_email_kwarg(self): |
780 | """The email is added as the first formatting argument.""" |
781 | - self.url = u'http://example.com/{0}/yadda/?something=else' |
782 | + self.url = 'http://example.com/{0}/yadda/?something=else' |
783 | yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN) |
784 | |
785 | expected = self.url.format(EMAIL) |
786 | @@ -284,7 +286,7 @@ |
787 | @defer.inlineCallbacks |
788 | def test_ping_url_formatting_no_format(self): |
789 | """The email is appended if formatting could not be accomplished.""" |
790 | - self.url = u'http://example.com/yadda/' |
791 | + self.url = 'http://example.com/yadda/' |
792 | yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN) |
793 | |
794 | expected = self.url + EMAIL |
795 | |
796 | === modified file 'ubuntu_sso/utils/ui.py' |
797 | --- ubuntu_sso/utils/ui.py 2012-04-09 17:38:24 +0000 |
798 | +++ ubuntu_sso/utils/ui.py 2012-08-14 23:18:19 +0000 |
799 | @@ -31,11 +31,15 @@ |
800 | import argparse |
801 | import re |
802 | import gettext |
803 | +import sys |
804 | |
805 | from ubuntu_sso.logger import setup_logging |
806 | |
807 | +INSTALL_KWARGS = {} |
808 | +if sys.version_info < (3,): |
809 | + INSTALL_KWARGS["unicode"] = True |
810 | |
811 | -gettext.install('ubuntu-sso-client', unicode=True) |
812 | +gettext.install('ubuntu-sso-client', **INSTALL_KWARGS) |
813 | logger = setup_logging('ubuntu_sso.utils.ui') |
814 | |
815 |
There will be one test failure until lp:~brian.curtin/ubuntu-sso-client/remove-SyncTimestampChecker lands. test_server_ date_sends_ nocache_ headers is the failing test.