Merge lp:~dobey/ubuntu-sso-client/update-4-2 into lp:ubuntu-sso-client/stable-4-2

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: no longer in the source branch.
Merged at revision: 1014
Proposed branch: lp:~dobey/ubuntu-sso-client/update-4-2
Merge into: lp:ubuntu-sso-client/stable-4-2
Diff against target: 231 lines (+163/-3)
5 files modified
ubuntu_sso/main/qt.py (+4/-1)
ubuntu_sso/main/tests/test_common.py (+1/-1)
ubuntu_sso/main/tests/test_qt.py (+15/-1)
ubuntu_sso/utils/locale.py (+47/-0)
ubuntu_sso/utils/tests/test_locale.py (+96/-0)
To merge this branch: bzr merge lp:~dobey/ubuntu-sso-client/update-4-2
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+144769@code.launchpad.net

Commit message

[Alejandro Cura]

    - Clean up timers that are sometimes slowing down all tests that follow.
    - Use a standard LC_CTYPE locale when the LANG is turkish. (LP: #997326).

[Rodney Dawes]

    - Fail the defer with an exception class like it's supposed to.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (92.9 KiB)

The attempt to merge lp:~dobey/ubuntu-sso-client/update-4-2 into lp:ubuntu-sso-client/stable-4-2 failed. Below is the output from the failed tests.

*** Running QT test suite for ubuntu_sso ***
running build
Compiled data/qt/ssl_dialog.ui into ubuntu_sso/qt/ui/ssl_dialog_ui.py
Compiled data/qt/proxy_credentials_dialog.ui into ubuntu_sso/qt/ui/proxy_credentials_dialog_ui.py
Compiled data/qt/loadingoverlay.ui into ubuntu_sso/qt/ui/loadingoverlay_ui.py
Compiled data/qt/setup_account.ui into ubuntu_sso/qt/ui/setup_account_ui.py
Compiled data/qt/email_verification.ui into ubuntu_sso/qt/ui/email_verification_ui.py
Compiled data/qt/error_message.ui into ubuntu_sso/qt/ui/error_message_ui.py
Compiled data/qt/network_detection.ui into ubuntu_sso/qt/ui/network_detection_ui.py
Compiled data/qt/forgotten_password.ui into ubuntu_sso/qt/ui/forgotten_password_ui.py
Compiled data/qt/current_user_sign_in.ui into ubuntu_sso/qt/ui/current_user_sign_in_ui.py
compiled data/qt/resources.qrc into ubuntu_sso/qt/ui/resources_rc.py
Compiled data/qt/success_message.ui into ubuntu_sso/qt/ui/success_message_ui.py
Compiled data/qt/reset_password.ui into ubuntu_sso/qt/ui/reset_password_ui.py
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/ubuntu_sso
copying ubuntu_sso/credentials.py -> build/lib.linux-x86_64-2.7/ubuntu_sso
copying ubuntu_sso/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso
copying ubuntu_sso/account.py -> build/lib.linux-x86_64-2.7/ubuntu_sso
copying ubuntu_sso/logger.py -> build/lib.linux-x86_64-2.7/ubuntu_sso
creating build/lib.linux-x86_64-2.7/ubuntu_sso/tests
copying ubuntu_sso/tests/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/tests
copying ubuntu_sso/tests/test_credentials.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/tests
copying ubuntu_sso/tests/linux.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/tests
copying ubuntu_sso/tests/test_account.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/tests
creating build/lib.linux-x86_64-2.7/ubuntu_sso/keyring
copying ubuntu_sso/keyring/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring
copying ubuntu_sso/keyring/pykeyring.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring
copying ubuntu_sso/keyring/linux.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring
creating build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
copying ubuntu_sso/keyring/tests/test_pykeyring.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
copying ubuntu_sso/keyring/tests/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
copying ubuntu_sso/keyring/tests/test_linux.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
copying ubuntu_sso/keyring/tests/test_common.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
creating build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/glib.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/linux.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/windows.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/qt.py -> build/lib.linux-x86_64-2.7...

1014. By Alejandro J. Cura

[Alejandro Cura]

    - Clean up timers that are sometimes slowing down all tests that follow.
    - Use a standard LC_CTYPE locale when the LANG is turkish. (LP: #997326).

[Rodney Dawes]

    - Fail the defer with an exception class like it's supposed to.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/main/qt.py'
2--- ubuntu_sso/main/qt.py 2012-04-09 17:38:24 +0000
3+++ ubuntu_sso/main/qt.py 2013-01-25 15:39:24 +0000
4@@ -1,6 +1,6 @@
5 # -*- coding: utf-8 -*-
6 #
7-# Copyright 2012 Canonical Ltd.
8+# Copyright 2012-2013 Canonical Ltd.
9 #
10 # This program is free software: you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License version 3, as published
12@@ -38,6 +38,8 @@
13
14 from PyQt4 import QtCore
15
16+from ubuntu_sso.utils.locale import fix_turkish_locale
17+
18
19 TIMERS = set()
20
21@@ -72,6 +74,7 @@
22
23 def start_setup():
24 """Setup the env to run the service."""
25+ fix_turkish_locale()
26 # this has to be created before calling dbus.mainloop.qt.DBusQtMainLoop
27 loop = QtCore.QCoreApplication(sys.argv)
28 dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True)
29
30=== modified file 'ubuntu_sso/main/tests/test_common.py'
31--- ubuntu_sso/main/tests/test_common.py 2012-07-30 19:04:33 +0000
32+++ ubuntu_sso/main/tests/test_common.py 2013-01-25 15:39:24 +0000
33@@ -684,7 +684,7 @@
34 def in_the_middle():
35 """Store the ref_count value."""
36 counter.append(self.obj.ref_count)
37- return defer.fail('foo')
38+ return defer.fail(SampleException('foo'))
39
40 self.patch(self.factory.credentials, 'find_credentials', in_the_middle)
41 self.obj.find_credentials(APP_NAME, self.args,
42
43=== modified file 'ubuntu_sso/main/tests/test_qt.py'
44--- ubuntu_sso/main/tests/test_qt.py 2012-04-09 17:38:24 +0000
45+++ ubuntu_sso/main/tests/test_qt.py 2013-01-25 15:39:24 +0000
46@@ -1,6 +1,6 @@
47 # -*- coding: utf-8 -*-
48 #
49-# Copyright 2012 Canonical Ltd.
50+# Copyright 2012-2013 Canonical Ltd.
51 #
52 # This program is free software: you can redistribute it and/or modify it
53 # under the terms of the GNU General Public License version 3, as published
54@@ -41,6 +41,8 @@
55
56 def clean_timers(self):
57 """Remove all timers."""
58+ for timer in qt.TIMERS:
59+ timer.stop()
60 qt.TIMERS = set()
61
62 @defer.inlineCallbacks
63@@ -80,3 +82,15 @@
64 qt.timeout_func(0, self._set_called, 1, name="a")
65 QtCore.QCoreApplication.instance().processEvents()
66 self.assertEqual(self._called, ((1,), {"name": "a"}))
67+
68+ def test_start_setup_calls_turkish_fix(self):
69+ """The start_setup function calls the turkish fix function."""
70+ self.patch(qt.QtCore, "QCoreApplication",
71+ lambda *args, **kwargs: object())
72+ self.patch(qt.dbus.mainloop.qt, "DBusQtMainLoop",
73+ lambda **kwargs: None)
74+ called = []
75+ self.patch(qt, "fix_turkish_locale", lambda: called.append(1))
76+
77+ qt.start_setup()
78+ self.assertEqual(called, [1])
79
80=== added file 'ubuntu_sso/utils/locale.py'
81--- ubuntu_sso/utils/locale.py 1970-01-01 00:00:00 +0000
82+++ ubuntu_sso/utils/locale.py 2013-01-25 15:39:24 +0000
83@@ -0,0 +1,47 @@
84+# -*- coding: utf-8 -*-
85+#
86+# Copyright 2013 Canonical Ltd.
87+#
88+# This program is free software: you can redistribute it and/or modify it
89+# under the terms of the GNU General Public License version 3, as published
90+# by the Free Software Foundation.
91+#
92+# This program is distributed in the hope that it will be useful, but
93+# WITHOUT ANY WARRANTY; without even the implied warranties of
94+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
95+# PURPOSE. See the GNU General Public License for more details.
96+#
97+# You should have received a copy of the GNU General Public License along
98+# with this program. If not, see <http://www.gnu.org/licenses/>.
99+#
100+# In addition, as a special exception, the copyright holders give
101+# permission to link the code of portions of this program with the
102+# OpenSSL library under certain conditions as described in each
103+# individual source file, and distribute linked combinations
104+# including the two.
105+# You must obey the GNU General Public License in all respects
106+# for all of the code used other than OpenSSL. If you modify
107+# file(s) with this exception, you may extend this exception to your
108+# version of the file(s), but you are not obligated to do so. If you
109+# do not wish to do so, delete this exception statement from your
110+# version. If you delete this exception statement from all source
111+# files in the program, then also delete it here.
112+"""Utility modules related to locale."""
113+
114+import os
115+
116+# this locale is always installed in Ubuntu
117+SAFE_LOCALE = "en_US.UTF-8"
118+
119+
120+def is_turkish(locale_identifier):
121+ """Return whether the locale identifier is turkish."""
122+ return locale_identifier.startswith("tr_")
123+
124+
125+def fix_turkish_locale():
126+ """Change the LC_CTYPE when the LANG is turkish. Fixes lp:997326"""
127+ lang = os.environ.get("LANG", "")
128+ ctype = os.environ.get("LC_CTYPE", "")
129+ if (is_turkish(lang) and ctype == "") or is_turkish(ctype):
130+ os.environ["LC_CTYPE"] = SAFE_LOCALE
131
132=== added file 'ubuntu_sso/utils/tests/test_locale.py'
133--- ubuntu_sso/utils/tests/test_locale.py 1970-01-01 00:00:00 +0000
134+++ ubuntu_sso/utils/tests/test_locale.py 2013-01-25 15:39:24 +0000
135@@ -0,0 +1,96 @@
136+# -*- coding: utf-8 -*-
137+#
138+# Copyright 2013 Canonical Ltd.
139+#
140+# This program is free software: you can redistribute it and/or modify it
141+# under the terms of the GNU General Public License version 3, as published
142+# by the Free Software Foundation.
143+#
144+# This program is distributed in the hope that it will be useful, but
145+# WITHOUT ANY WARRANTY; without even the implied warranties of
146+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
147+# PURPOSE. See the GNU General Public License for more details.
148+#
149+# You should have received a copy of the GNU General Public License along
150+# with this program. If not, see <http://www.gnu.org/licenses/>.
151+#
152+# In addition, as a special exception, the copyright holders give
153+# permission to link the code of portions of this program with the
154+# OpenSSL library under certain conditions as described in each
155+# individual source file, and distribute linked combinations
156+# including the two.
157+# You must obey the GNU General Public License in all respects
158+# for all of the code used other than OpenSSL. If you modify
159+# file(s) with this exception, you may extend this exception to your
160+# version of the file(s), but you are not obligated to do so. If you
161+# do not wish to do so, delete this exception statement from your
162+# version. If you delete this exception statement from all source
163+# files in the program, then also delete it here.
164+"""Tests for the locale utilities."""
165+
166+from twisted.trial.unittest import TestCase
167+
168+from ubuntu_sso.utils import locale
169+
170+NO_VALUE = object()
171+
172+
173+class LocaleTestCase(TestCase):
174+ """Test case for functions related to locale."""
175+
176+ def setUp(self):
177+ d = super(LocaleTestCase, self).setUp()
178+ self.save_environ("LC_CTYPE")
179+ self.save_environ("LANG")
180+ return d
181+
182+ def save_environ(self, env_var_name):
183+ """Save the value of an environment variable."""
184+ old_value = locale.os.environ.get(env_var_name, NO_VALUE)
185+ self.addCleanup(self.restore_environ, env_var_name, old_value)
186+ locale.os.environ[env_var_name] = "fake_locale"
187+
188+ def restore_environ(self, env_var_name, old_value):
189+ """Restore the value of an environment variable."""
190+ if old_value is NO_VALUE:
191+ if env_var_name in locale.os.environ:
192+ del(locale.os.environ[env_var_name])
193+ else:
194+ locale.os.environ[env_var_name] = old_value
195+
196+ def test_fix_turkish_locale_when_turkish(self):
197+ """The fix_turkish_locale function skips when no locale set."""
198+ locale.os.environ["LANG"] = "tr_TR.UTF-8"
199+ del(locale.os.environ["LC_CTYPE"])
200+ locale.fix_turkish_locale()
201+ self.assertEqual(locale.os.environ["LC_CTYPE"], locale.SAFE_LOCALE)
202+
203+ def test_fix_turkish_locale_when_other(self):
204+ """The fix_turkish_locale function skips when no locale set."""
205+ locale.os.environ["LANG"] = "en_EN.UTF-8"
206+ del(locale.os.environ["LC_CTYPE"])
207+ locale.fix_turkish_locale()
208+ self.assertEqual(locale.os.environ.get("LC_CTYPE", NO_VALUE), NO_VALUE)
209+
210+ def test_fix_turkish_locale_when_LANG_unset(self):
211+ """The fix_turkish_locale function skips when no locale set."""
212+ del(locale.os.environ["LANG"])
213+ del(locale.os.environ["LC_CTYPE"])
214+ locale.fix_turkish_locale()
215+ self.assertEqual(locale.os.environ.get("LC_CTYPE", NO_VALUE), NO_VALUE)
216+
217+ def test_fix_turkish_locale_when_LC_CTYPE_not_turkish(self):
218+ """The fix is skipped if the LC_CTYPE is already non-turkish."""
219+ original = "es_ES.UTF-8"
220+ locale.os.environ["LANG"] = "tr_TR.UTF-8"
221+ locale.os.environ["LC_CTYPE"] = original
222+ locale.fix_turkish_locale()
223+ self.assertEqual(locale.os.environ.get("LC_CTYPE", NO_VALUE), original)
224+
225+ def test_fix_turkish_locale_when_LC_CTYPE_is_turkish(self):
226+ """The fix is applied if the LC_CTYPE is turkish."""
227+ locale.os.environ["LANG"] = "es_ES.UTF-8"
228+ locale.os.environ["LC_CTYPE"] = "tr_TR.UTF-8"
229+ locale.fix_turkish_locale()
230+ self.assertEqual(locale.os.environ.get("LC_CTYPE", NO_VALUE),
231+ locale.SAFE_LOCALE)

Subscribers

People subscribed via source and target branches

to all changes: