Merge lp:~bjornt/landscape-client/gir-test-failures into lp:~landscape/landscape-client/trunk

Proposed by Björn Tillenius
Status: Merged
Approved by: Thomas Herve
Approved revision: 623
Merged at revision: 625
Proposed branch: lp:~bjornt/landscape-client/gir-test-failures
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 439 lines (+63/-102)
10 files modified
landscape/ui/controller/tests/test_app.py (+5/-7)
landscape/ui/controller/tests/test_configuration.py (+4/-8)
landscape/ui/model/configuration/tests/test_mechanism.py (+8/-12)
landscape/ui/model/configuration/tests/test_proxy.py (+4/-10)
landscape/ui/model/configuration/tests/test_state.py (+9/-19)
landscape/ui/model/configuration/tests/test_uisettings.py (+3/-3)
landscape/ui/model/registration/tests/test_mechanism.py (+7/-14)
landscape/ui/model/registration/tests/test_proxy.py (+9/-16)
landscape/ui/tests/helpers.py (+5/-4)
landscape/ui/view/tests/test_configuration.py (+9/-9)
To merge this branch: bzr merge lp:~bjornt/landscape-client/gir-test-failures
Reviewer Review Type Date Requested Status
Jerry Seutter (community) Approve
Thomas Herve (community) Approve
Review via email: mp+148412@code.launchpad.net

Commit message

Make ui tests skpi when GIR is available but dbus isn't.

Description of the change

The landscape/ui tests are failing when gobject introspection is available, but
dbus isn't. The reason for this is that some tests checks only whether GIR is
available, even though they depend on dbus.

I've changed it so that we only have one variable to control whether the tests
should be skipped and change the skip message depending on what's missing.

It might be possible to run some of the tests with only GIR available, but I
don't think it's worth the trouble trying to do that. Better to keep it easier
and run all the tests when you need to.

To post a comment you must log in.
Revision history for this message
Jerry Seutter (jseutter) wrote :

The changes look good, but I get a problem on my machine.

trunk:

===============================================================================
[SKIPPED]
imagestore module not available

landscape.manager.tests.test_eucalyptus.EucalyptusTest.test_failed_run_stops_service_hub
landscape.manager.tests.test_eucalyptus.EucalyptusTest.test_run_with_failure_message
landscape.manager.tests.test_eucalyptus.EucalyptusTest.test_run_with_successful_message
landscape.manager.tests.test_eucalyptus.EucalyptusTest.test_successful_run_stops_service_hub
landscape.manager.tests.test_eucalyptus.GetEucalyptusInfoTest.test_wb_get_eucalyptus_info
landscape.manager.tests.test_eucalyptus.StartServiceHubTest.test_start_service_hub
landscape.manager.tests.test_eucalyptus.StartServiceHubTest.test_start_service_hub_with_existing_data_dir
-------------------------------------------------------------------------------
Ran 2245 tests in 147.100s

PASSED (skips=7, successes=2238)

And your branch:

===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/jseutter/src/landscape-client/gir-test-failures/landscape/ui/model/registration/tests/test_mechanism.py", line 19, in setUp
    self.bus_name = dbus.service.BusName(INTERFACE_NAME, MechanismTest.bus)
exceptions.AttributeError: type object 'MechanismTest' has no attribute 'bus'

landscape.ui.model.registration.tests.test_mechanism.MechanismTest.test_disabling_fail
landscape.ui.model.registration.tests.test_mechanism.MechanismTest.test_disabling_succeed
landscape.ui.model.registration.tests.test_mechanism.MechanismTest.test_exit
landscape.ui.model.registration.tests.test_mechanism.MechanismTest.test_registration_fail
landscape.ui.model.registration.tests.test_mechanism.MechanismTest.test_registration_succeed
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/jseutter/src/landscape-client/gir-test-failures/landscape/ui/model/registration/tests/test_proxy.py", line 81, in setUp
    RegistrationProxyTest.bus)
exceptions.AttributeError: type object 'RegistrationProxyTest' has no attribute 'bus'

landscape.ui.model.registration.tests.test_proxy.RegistrationProxyTest.test_disable
landscape.ui.model.registration.tests.test_proxy.RegistrationProxyTest.test_exit
landscape.ui.model.registration.tests.test_proxy.RegistrationProxyTest.test_register
-------------------------------------------------------------------------------
Ran 2244 tests in 145.865s

FAILED (skips=7, errors=29, successes=2208)

I haven't looked into the problem any deeper.

Revision history for this message
Thomas Herve (therve) wrote :

Yeah it's not working for me either, I'm on precise FWIW.

review: Needs Fixing
623. By Björn Tillenius

Set up the bus for the tests that need it.

Revision history for this message
Björn Tillenius (bjornt) wrote :

On Mon, Feb 18, 2013 at 09:31:26AM -0000, Thomas Herve wrote:
> Review: Needs Fixing
>
> Yeah it's not working for me either, I'm on precise FWIW.

Ah, sorry. Some of the code that checked whether dbus was available
actually set up the bus as well. I've added that setup to the setUp()
method for the affected tests. I've confirmed that it works on trunk
with dbus available.

--
Björn Tillenius | https://launchpad.net/~bjornt

Revision history for this message
Thomas Herve (therve) wrote :

Cool, +1!

review: Approve
Revision history for this message
Jerry Seutter (jseutter) wrote :

+1, looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/ui/controller/tests/test_app.py'
2--- landscape/ui/controller/tests/test_app.py 2012-05-15 17:30:38 +0000
3+++ landscape/ui/controller/tests/test_app.py 2013-02-18 13:49:27 +0000
4@@ -2,9 +2,9 @@
5
6 from landscape.ui.tests.helpers import (
7 ConfigurationProxyHelper, dbus_test_should_skip, dbus_skip_message,
8- got_gobject_introspection, gobject_skip_message, FakeGSettings)
9+ FakeGSettings)
10
11-if got_gobject_introspection:
12+if not dbus_test_should_skip:
13 from gi.repository import Gtk
14 from landscape.ui.controller.app import SettingsApplicationController
15 from landscape.ui.controller.configuration import ConfigController
16@@ -66,8 +66,8 @@
17 app = ConnectionRecordingSettingsApplicationController()
18 self.assertTrue(app.is_connected("activate", app.setup_ui))
19
20- if not got_gobject_introspection:
21- skip = gobject_skip_message
22+ if dbus_test_should_skip:
23+ skip = dbus_skip_message
24
25
26 class SettingsApplicationControllerUISetupTest(LandscapeTest):
27@@ -131,7 +131,5 @@
28 self.assertIsInstance(self.app.settings_dialog.controller,
29 ConfigController)
30
31- if not got_gobject_introspection:
32- skip = gobject_skip_message
33- elif dbus_test_should_skip:
34+ if dbus_test_should_skip:
35 skip = dbus_skip_message
36
37=== modified file 'landscape/ui/controller/tests/test_configuration.py'
38--- landscape/ui/controller/tests/test_configuration.py 2012-05-15 17:30:38 +0000
39+++ landscape/ui/controller/tests/test_configuration.py 2013-02-18 13:49:27 +0000
40@@ -1,8 +1,8 @@
41 from landscape.ui.tests.helpers import (
42 ConfigurationProxyHelper, dbus_test_should_skip, dbus_skip_message,
43- FakeGSettings, got_gobject_introspection, gobject_skip_message)
44+ FakeGSettings)
45
46-if got_gobject_introspection:
47+if not dbus_test_should_skip:
48 from landscape.ui.controller.configuration import ConfigController
49 import landscape.ui.model.configuration.state
50 from landscape.ui.model.configuration.state import (
51@@ -162,9 +162,7 @@
52 self.assertEqual("landscape.localdomain",
53 self.controller.local_landscape_host)
54
55- if not got_gobject_introspection:
56- skip = gobject_skip_message
57- elif dbus_test_should_skip:
58+ if dbus_test_should_skip:
59 skip = dbus_skip_message
60
61
62@@ -206,7 +204,5 @@
63 self.assertEqual("", self.controller.local_password)
64 self.assertEqual("me.here.com", self.controller.computer_title)
65
66- if not got_gobject_introspection:
67- skip = gobject_skip_message
68- elif dbus_test_should_skip:
69+ if dbus_test_should_skip:
70 skip = dbus_skip_message
71
72=== modified file 'landscape/ui/model/configuration/tests/test_mechanism.py'
73--- landscape/ui/model/configuration/tests/test_mechanism.py 2012-05-15 17:30:38 +0000
74+++ landscape/ui/model/configuration/tests/test_mechanism.py 2013-02-18 13:49:27 +0000
75@@ -1,10 +1,10 @@
76-import dbus
77
78 from landscape.configuration import LandscapeSetupConfiguration
79 from landscape.tests.helpers import LandscapeTest
80 from landscape.ui.tests.helpers import (
81- got_gobject_introspection, gobject_skip_message)
82-if got_gobject_introspection:
83+ dbus_test_should_skip, dbus_skip_message)
84+if not dbus_test_should_skip:
85+ import dbus
86 from landscape.ui.model.configuration.mechanism import (
87 ConfigurationMechanism, INTERFACE_NAME)
88
89@@ -33,7 +33,9 @@
90 default_config_filenames = [self.config_filename]
91
92 self.config = MyLandscapeSetupConfiguration()
93- bus_name = dbus.service.BusName(INTERFACE_NAME, MechanismTest.bus)
94+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
95+ bus = dbus.SessionBus(private=True)
96+ bus_name = dbus.service.BusName(INTERFACE_NAME, bus)
97 self.mechanism = ConfigurationMechanism(self.config, bus_name)
98 self.config.load(["-c", self.config_filename])
99
100@@ -200,11 +202,5 @@
101 """
102 self.assertRaises(SystemExit, self.mechanism.exit)
103
104- if not got_gobject_introspection:
105- skip = gobject_skip_message
106- else:
107- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
108- try:
109- bus = dbus.SessionBus(private=True)
110- except dbus.exceptions.DBusException:
111- skip = "Cannot create private DBus session without X11"
112+ if dbus_test_should_skip:
113+ skip = dbus_skip_message
114
115=== modified file 'landscape/ui/model/configuration/tests/test_proxy.py'
116--- landscape/ui/model/configuration/tests/test_proxy.py 2012-05-15 17:30:38 +0000
117+++ landscape/ui/model/configuration/tests/test_proxy.py 2013-02-18 13:49:27 +0000
118@@ -1,11 +1,9 @@
119 from landscape.configuration import LandscapeSetupConfiguration
120 from landscape.ui.tests.helpers import (
121- ConfigurationProxyHelper, dbus_test_should_skip, dbus_skip_message,
122- got_gobject_introspection, gobject_skip_message)
123-if got_gobject_introspection:
124+ ConfigurationProxyHelper, dbus_test_should_skip, dbus_skip_message)
125+if not dbus_test_should_skip:
126 from landscape.ui.model.configuration.mechanism import (
127 PermissionDeniedByPolicy)
128-if not dbus_test_should_skip:
129 import dbus
130 from landscape.tests.helpers import LandscapeTest
131
132@@ -52,9 +50,7 @@
133 self.mechanism.load = fake_timeout_failure_load
134 self.assertFalse(self.proxy.load([]))
135
136- if not got_gobject_introspection:
137- skip = gobject_skip_message
138- elif dbus_test_should_skip:
139+ if dbus_test_should_skip:
140 skip = dbus_skip_message
141
142
143@@ -187,7 +183,5 @@
144 """
145 self.assertRaises(SystemExit, self.proxy.exit, asynchronous=False)
146
147- if not got_gobject_introspection:
148- skip = gobject_skip_message
149- elif dbus_test_should_skip:
150+ if dbus_test_should_skip:
151 skip = dbus_skip_message
152
153=== modified file 'landscape/ui/model/configuration/tests/test_state.py'
154--- landscape/ui/model/configuration/tests/test_state.py 2012-05-15 17:30:38 +0000
155+++ landscape/ui/model/configuration/tests/test_state.py 2013-02-18 13:49:27 +0000
156@@ -1,8 +1,8 @@
157 from landscape.ui.tests.helpers import (
158 ConfigurationProxyHelper, FakeGSettings, dbus_test_should_skip,
159- dbus_skip_message, gobject_skip_message, got_gobject_introspection)
160+ dbus_skip_message)
161
162-if got_gobject_introspection:
163+if not dbus_test_should_skip:
164 from landscape.ui.model.configuration.uisettings import UISettings
165 import landscape.ui.model.configuration.state
166 from landscape.ui.model.configuration.state import (
167@@ -64,8 +64,8 @@
168 exit_method=fake_exit_method))
169 self.assertTrue(isinstance(model.get_state(), ExitedState))
170
171- if not got_gobject_introspection:
172- skip = gobject_skip_message
173+ if dbus_test_should_skip:
174+ skip = dbus_skip_message
175
176
177 class ConfigurationModelTest(LandscapeTest):
178@@ -253,9 +253,7 @@
179 model = ConfigurationModel(proxy=self.proxy, uisettings=uisettings)
180 self.assertRaises(SystemExit, model.exit, asynchronous=False)
181
182- if not got_gobject_introspection:
183- skip = gobject_skip_message
184- elif dbus_test_should_skip:
185+ if dbus_test_should_skip:
186 skip = dbus_skip_message
187
188
189@@ -313,9 +311,7 @@
190 self.assertEqual("CrazyHorse", model.local_account_name)
191 self.assertEqual("boink", model.hosted_password)
192
193- if not got_gobject_introspection:
194- skip = gobject_skip_message
195- elif dbus_test_should_skip:
196+ if dbus_test_should_skip:
197 skip = dbus_skip_message
198
199
200@@ -364,9 +360,7 @@
201 self.assertEqual("Vivadixiesubmarinetransmissionplot",
202 model.hosted_password)
203
204- if not got_gobject_introspection:
205- skip = gobject_skip_message
206- elif dbus_test_should_skip:
207+ if dbus_test_should_skip:
208 skip = dbus_skip_message
209
210
211@@ -580,9 +574,7 @@
212 self.assertRaises(StateError, state.persist)
213 self.assertRaises(StateError, state.revert)
214
215- if not got_gobject_introspection:
216- skip = gobject_skip_message
217- elif dbus_test_should_skip:
218+ if dbus_test_should_skip:
219 skip = dbus_skip_message
220
221
222@@ -639,7 +631,5 @@
223 self.assertEqual("ThomasPaine", self.proxy.account_name)
224 self.assertEqual("TheAgeOfReason", self.proxy.registration_key)
225
226- if not got_gobject_introspection:
227- skip = gobject_skip_message
228- elif dbus_test_should_skip:
229+ if dbus_test_should_skip:
230 skip = dbus_skip_message
231
232=== modified file 'landscape/ui/model/configuration/tests/test_uisettings.py'
233--- landscape/ui/model/configuration/tests/test_uisettings.py 2012-03-06 15:17:13 +0000
234+++ landscape/ui/model/configuration/tests/test_uisettings.py 2013-02-18 13:49:27 +0000
235@@ -2,7 +2,7 @@
236 from landscape.tests.helpers import LandscapeTest
237 from landscape.ui.model.configuration.uisettings import UISettings
238 from landscape.ui.tests.helpers import (
239- FakeGSettings, got_gobject_introspection, gobject_skip_message)
240+ FakeGSettings, dbus_test_should_skip, dbus_skip_message)
241
242
243 class UISettingsTest(LandscapeTest):
244@@ -163,5 +163,5 @@
245 self.uisettings.set_local_password("Bang")
246 self.assertEqual("Bang", self.uisettings.get_local_password())
247
248- if not got_gobject_introspection:
249- skip = gobject_skip_message
250+ if dbus_test_should_skip:
251+ skip = dbus_skip_message
252
253=== modified file 'landscape/ui/model/registration/tests/test_mechanism.py'
254--- landscape/ui/model/registration/tests/test_mechanism.py 2012-03-15 15:12:51 +0000
255+++ landscape/ui/model/registration/tests/test_mechanism.py 2013-02-18 13:49:27 +0000
256@@ -1,9 +1,8 @@
257 import dbus
258
259 from landscape.tests.helpers import LandscapeTest
260-from landscape.ui.tests.helpers import (
261- got_gobject_introspection, gobject_skip_message)
262-if got_gobject_introspection:
263+from landscape.ui.tests.helpers import dbus_test_should_skip, dbus_skip_message
264+if not dbus_test_should_skip:
265 from landscape.ui.model.registration.mechanism import (
266 RegistrationMechanism, INTERFACE_NAME)
267
268@@ -17,7 +16,9 @@
269
270 def setUp(self):
271 super(MechanismTest, self).setUp()
272- self.bus_name = dbus.service.BusName(INTERFACE_NAME, MechanismTest.bus)
273+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
274+ bus = dbus.SessionBus(private=True)
275+ self.bus_name = dbus.service.BusName(INTERFACE_NAME, bus)
276 self.mechanism = None
277
278 def tearDown(self):
279@@ -95,13 +96,5 @@
280 self.mechanism = RegistrationMechanism(self.bus_name)
281 self.assertRaises(SystemExit, self.mechanism.exit)
282
283- if not got_gobject_introspection:
284- skip = gobject_skip_message
285- else:
286- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
287- try:
288- bus = dbus.SessionBus(private=True)
289- except dbus.exceptions.DBusException:
290- skip_string = "Cannot launch private DBus session without X11"
291- test_registration_succeed.skip = skip_string
292- test_registration_fail.skip = skip_string
293+ if dbus_test_should_skip:
294+ skip = dbus_skip_message
295
296=== modified file 'landscape/ui/model/registration/tests/test_proxy.py'
297--- landscape/ui/model/registration/tests/test_proxy.py 2012-03-15 15:12:51 +0000
298+++ landscape/ui/model/registration/tests/test_proxy.py 2013-02-18 13:49:27 +0000
299@@ -1,9 +1,8 @@
300 import dbus
301
302 from landscape.tests.helpers import LandscapeTest
303-from landscape.ui.tests.helpers import (
304- got_gobject_introspection, gobject_skip_message)
305-if got_gobject_introspection:
306+from landscape.ui.tests.helpers import dbus_test_should_skip, dbus_skip_message
307+if not dbus_test_should_skip:
308 from landscape.ui.model.registration.mechanism import (
309 RegistrationMechanism, INTERFACE_NAME)
310 from landscape.ui.model.registration.proxy import RegistrationProxy
311@@ -66,8 +65,8 @@
312 [message] = self.error_handler_messages
313 self.assertEqual("Registration timed out.", message)
314
315- if not got_gobject_introspection:
316- skip = gobject_skip_message
317+ if dbus_test_should_skip:
318+ skip = dbus_skip_message
319
320
321 class RegistrationProxyTest(LandscapeTest):
322@@ -78,8 +77,9 @@
323
324 def setUp(self):
325 super(RegistrationProxyTest, self).setUp()
326- bus_name = dbus.service.BusName(INTERFACE_NAME,
327- RegistrationProxyTest.bus)
328+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
329+ bus = dbus.SessionBus(private=True)
330+ bus_name = dbus.service.BusName(INTERFACE_NAME, bus)
331
332 def fake_do__registration(this, config_path):
333 return True, ""
334@@ -137,12 +137,5 @@
335 """
336 self.assertRaises(SystemExit, self.proxy.exit)
337
338- if not got_gobject_introspection:
339- skip = gobject_skip_message
340- else:
341- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
342- try:
343- bus = dbus.SessionBus(private=True)
344- except dbus.exceptions.DBusException:
345- test_register.skip = ("Cannot launch private DBus session without "
346- "X11")
347+ if dbus_test_should_skip:
348+ skip = dbus_skip_message
349
350=== modified file 'landscape/ui/tests/helpers.py'
351--- landscape/ui/tests/helpers.py 2012-03-16 12:09:19 +0000
352+++ landscape/ui/tests/helpers.py 2013-02-18 13:49:27 +0000
353@@ -5,18 +5,19 @@
354
355 from landscape.configuration import LandscapeSetupConfiguration
356
357+dbus_test_should_skip = False
358 dbus_skip_message = "Cannot launch private DBus session without X11"
359 try:
360 from gi.repository import GObject, Gtk
361 got_gobject_introspection = True
362 # Shut up pyflakes
363- gobject_skip_message = GObject._version + str(Gtk.MAJOR_VERSION)
364+ dbus_skip_message = GObject._version + str(Gtk.MAJOR_VERSION)
365 except (ImportError, RuntimeError):
366 got_gobject_introspection = False
367- gobject_skip_message = "GObject Introspection module unavailable"
368+ dbus_test_should_skip = True
369+ dbus_skip_message = "GObject Introspection module unavailable"
370 bus = object
371 bus_name = ""
372- dbus_test_should_skip = True
373
374
375 if got_gobject_introspection:
376@@ -28,7 +29,6 @@
377 # from dbus.service.Object which throws a fit if it notices you using
378 # it without a mainloop.
379 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
380- dbus_test_should_skip = False
381 try:
382 bus = dbus.SessionBus(private=True)
383 bus_name = dbus.service.BusName(INTERFACE_NAME, bus)
384@@ -36,6 +36,7 @@
385 bus = object
386 bus_name = ""
387 dbus_test_should_skip = True
388+ dbus_skip_message = "Cannot launch private DBus session without X11"
389
390
391 class ConfigurationProxyHelper(object):
392
393=== modified file 'landscape/ui/view/tests/test_configuration.py'
394--- landscape/ui/view/tests/test_configuration.py 2012-05-15 17:30:38 +0000
395+++ landscape/ui/view/tests/test_configuration.py 2013-02-18 13:49:27 +0000
396@@ -1,10 +1,10 @@
397 import sys
398
399 from landscape.ui.tests.helpers import (
400- ConfigurationProxyHelper, FakeGSettings, gobject_skip_message,
401- got_gobject_introspection, simulate_gtk_key_release, simulate_gtk_paste)
402+ ConfigurationProxyHelper, FakeGSettings, dbus_test_should_skip,
403+ dbus_skip_message, simulate_gtk_key_release, simulate_gtk_paste)
404
405-if got_gobject_introspection:
406+if not dbus_test_should_skip:
407 from gi.repository import Gtk
408 from landscape.ui.view.configuration import (
409 ClientSettingsDialog, sanitise_host_name, is_valid_host_name)
410@@ -57,8 +57,8 @@
411 """
412 self.assertFalse(is_valid_host_name(u"\xc3a"))
413
414- if not got_gobject_introspection:
415- skip = gobject_skip_message
416+ if dbus_test_should_skip:
417+ skip = dbus_skip_message
418
419
420 class ConfigurationViewTest(LandscapeTest):
421@@ -540,8 +540,8 @@
422 self.run_gtk_eventloop()
423 self.assertFalse(dialog.validity_check())
424
425- if not got_gobject_introspection:
426- skip = gobject_skip_message
427+ if dbus_test_should_skip:
428+ skip = dbus_skip_message
429
430
431 class LocalConfigurationViewTest(LandscapeTest):
432@@ -604,5 +604,5 @@
433 dialog.local_landscape_host_entry.get_text())
434 self.assertEqual("manky", dialog.local_password_entry.get_text())
435
436- if not got_gobject_introspection:
437- skip = gobject_skip_message
438+ if dbus_test_should_skip:
439+ skip = dbus_skip_message

Subscribers

People subscribed via source and target branches

to all changes: