Merge lp:~mvo/software-center/lp1047281 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3156
Proposed branch: lp:~mvo/software-center/lp1047281
Merge into: lp:software-center
Diff against target: 45 lines (+29/-1)
2 files modified
softwarecenter/ui/gtk3/widgets/labels.py (+1/-1)
tests/gtk3/test_regression_lp1047281.py (+28/-0)
To merge this branch: bzr merge lp:~mvo/software-center/lp1047281
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+123563@code.launchpad.net

Description of the change

This branch fixes the crash outlined in bug #1047281 and adds a
regression test. The test is in its own file as the import needs
to happen after the patching of the gettext call.

To manually reproudce you can run:
$ LANGUAGE=de ./software-center

after installing the german langpacks ("it" works as well).

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Does the trick perfectly! Wow, pretty strange little bug. Thank you, Michael!!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/widgets/labels.py'
2--- softwarecenter/ui/gtk3/widgets/labels.py 2012-06-11 14:50:53 +0000
3+++ softwarecenter/ui/gtk3/widgets/labels.py 2012-09-10 14:43:19 +0000
4@@ -31,7 +31,7 @@
5 # TRANSLATORS: symbol for "hardware-supported"
6 'yes': _(u'\u2713'),
7 # TRANSLATORS: symbol for hardware "not-supported"
8- 'no': u'<span foreground="red">%s</span>' % _(u'\u2718'),
9+ 'no': '<span foreground="red">%s</span>' % _(u'\u2718'),
10 }
11
12 # TRANSLATORS: this is a substring that used to build the
13
14=== added file 'tests/gtk3/test_regression_lp1047281.py'
15--- tests/gtk3/test_regression_lp1047281.py 1970-01-01 00:00:00 +0000
16+++ tests/gtk3/test_regression_lp1047281.py 2012-09-10 14:43:19 +0000
17@@ -0,0 +1,28 @@
18+import unittest
19+
20+from mock import patch
21+
22+from tests.utils import setup_test_env
23+setup_test_env()
24+
25+class RegressionTestCase(unittest.TestCase):
26+
27+ @patch("gettext.gettext")
28+ def test_lp1047281(self, mock_gettext):
29+ # add utf8 encoded data to the return string
30+ some_utf8_encoded_str = "\xe2\x80\x99"
31+ mock_gettext.return_value = some_utf8_encoded_str
32+
33+ # now import so that the problematic code is called
34+ from softwarecenter.ui.gtk3.widgets.labels import (
35+ HardwareRequirementsLabel)
36+
37+ # and ensure its not crashing
38+ label = HardwareRequirementsLabel()
39+ self.assertEqual(
40+ label.SUPPORTED_SYM['no'],
41+ '<span foreground="red">%s</span>' % some_utf8_encoded_str)
42+
43+
44+if __name__ == "__main__":
45+ unittest.main()

Subscribers

People subscribed via source and target branches