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
=== modified file 'ubuntu_sso/qt/tests/__init__.py'
--- ubuntu_sso/qt/tests/__init__.py 2012-03-14 17:14:07 +0000
+++ ubuntu_sso/qt/tests/__init__.py 2012-04-04 17:59:22 +0000
@@ -39,12 +39,14 @@
3939
4040
41def build_string_for_pixels(label, width):41def build_string_for_pixels(label, width):
42 """Return a random string that will be as big as with in pixels."""42 """Return a random string that will be as big as 'width' in pixels."""
43 char = 'a'43 char = 'm'
44 fm = QtGui.QFontMetrics(label.font())44 fm = QtGui.QFontMetrics(label.font())
45 pixel_width = fm.width(char)45 pixel_width = fm.width(char)
46 chars = int(width / pixel_width)46 chars = int(width / pixel_width)
47 return char * chars47 result = char * chars
48 assert pixel_width * chars <= width
49 return result
4850
4951
50class FakedObject(object):52class FakedObject(object):
5153
=== modified file 'ubuntu_sso/qt/tests/test_common.py'
--- ubuntu_sso/qt/tests/test_common.py 2012-03-15 19:16:15 +0000
+++ ubuntu_sso/qt/tests/test_common.py 2012-04-04 17:59:22 +0000
@@ -257,7 +257,7 @@
257257
258 def test_text_not_elided_if_too_short(self):258 def test_text_not_elided_if_too_short(self):
259 """If text is shorter than max_width, do not elide."""259 """If text is shorter than max_width, do not elide."""
260 text = build_string_for_pixels(self.ui, self.max_width - 1)260 text = build_string_for_pixels(self.ui, self.max_width - 10)
261261
262 maybe_elide_text(self.ui, text, self.max_width)262 maybe_elide_text(self.ui, text, self.max_width)
263263
@@ -277,7 +277,7 @@
277277
278 def test_text_elided_if_bigger_than_max_width(self):278 def test_text_elided_if_bigger_than_max_width(self):
279 """If text is equal than max_width, do not elide."""279 """If text is equal than max_width, do not elide."""
280 text = build_string_for_pixels(self.ui, self.max_width + 10)280 text = build_string_for_pixels(self.ui, self.max_width * 2)
281281
282 maybe_elide_text(self.ui, text, self.max_width)282 maybe_elide_text(self.ui, text, self.max_width)
283283

Subscribers

People subscribed via source and target branches