Merge lp:~nataliabidart/ubuntu-sso-client/fix-nigthlies-test into lp:ubuntu-sso-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 942
Merged at revision: 941
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/fix-nigthlies-test
Merge into: lp:ubuntu-sso-client
Diff against target: 42 lines (+7/-5)
2 files modified
ubuntu_sso/qt/tests/__init__.py (+5/-3)
ubuntu_sso/qt/tests/test_common.py (+2/-2)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/fix-nigthlies-test
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Review via email: mp+100850@code.launchpad.net

Commit message

- Making test more robust to prevent spurious failures (LP: #973345).

To post a comment you must log in.
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Let's hope this fixes the issue.
If it does not, I have a few more ideas to try to fix this test in the nightlies.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/qt/tests/__init__.py'
2--- ubuntu_sso/qt/tests/__init__.py 2012-03-14 17:14:07 +0000
3+++ ubuntu_sso/qt/tests/__init__.py 2012-04-04 17:59:22 +0000
4@@ -39,12 +39,14 @@
5
6
7 def build_string_for_pixels(label, width):
8- """Return a random string that will be as big as with in pixels."""
9- char = 'a'
10+ """Return a random string that will be as big as 'width' in pixels."""
11+ char = 'm'
12 fm = QtGui.QFontMetrics(label.font())
13 pixel_width = fm.width(char)
14 chars = int(width / pixel_width)
15- return char * chars
16+ result = char * chars
17+ assert pixel_width * chars <= width
18+ return result
19
20
21 class FakedObject(object):
22
23=== modified file 'ubuntu_sso/qt/tests/test_common.py'
24--- ubuntu_sso/qt/tests/test_common.py 2012-03-15 19:16:15 +0000
25+++ ubuntu_sso/qt/tests/test_common.py 2012-04-04 17:59:22 +0000
26@@ -257,7 +257,7 @@
27
28 def test_text_not_elided_if_too_short(self):
29 """If text is shorter than max_width, do not elide."""
30- text = build_string_for_pixels(self.ui, self.max_width - 1)
31+ text = build_string_for_pixels(self.ui, self.max_width - 10)
32
33 maybe_elide_text(self.ui, text, self.max_width)
34
35@@ -277,7 +277,7 @@
36
37 def test_text_elided_if_bigger_than_max_width(self):
38 """If text is equal than max_width, do not elide."""
39- text = build_string_for_pixels(self.ui, self.max_width + 10)
40+ text = build_string_for_pixels(self.ui, self.max_width * 2)
41
42 maybe_elide_text(self.ui, text, self.max_width)
43

Subscribers

People subscribed via source and target branches