Logo Search packages:      
Sourcecode: ubuntuone-dev-tools version File versions  Download package

def ubuntuone::devtools::testcase::DBusTestCase::setUp (   self )
Setup the infrastructure fo the test (dbus service).

Definition at line 216 of file testcase.py.

                   :
        """Setup the infrastructure fo the test (dbus service)."""
        # Class 'BaseTestCase' has no 'setUp' member
        # pylint: disable=E1101
        # dbus modules will be imported by the decorator
        # pylint: disable=E0602
        yield super(DBusTestCase, self).setUp()

        # We need to ensure DBUS_SESSION_BUS_ADDRESS is private here
        from urllib import unquote
        bus_address = os.environ.get('DBUS_SESSION_BUS_ADDRESS', None)
        if os.path.dirname(unquote(bus_address.split(',')[0].split('=')[1])) \
                != os.path.dirname(os.getcwd()):
            raise InvalidSessionBus('DBUS_SESSION_BUS_ADDRES is wrong.')

        # Set up the main loop and bus connection
        self.loop = DBusGMainLoop(set_as_default=True)
        self.bus = dbus.bus.BusConnection(address_or_type=bus_address,
                                          mainloop=self.loop)

        # Monkeypatch the dbus.SessionBus/SystemBus methods, to ensure we
        # always point at our own private bus instance.
        self.patch(dbus, 'SessionBus', lambda: self.bus)
        self.patch(dbus, 'SystemBus', lambda: self.bus)

        # Check that we are on the correct bus for real
# Disable this for now, because our tests are extremely broken :(
#        bus_names = self.bus.list_names()
#        if len(bus_names) > 2:
#            raise InvalidSessionBus('Too many bus connections: %s (%r)' %
#                                    (len(bus_names), bus_names))

        # monkeypatch busName.__del__ to avoid errors on gc
        # we take care of releasing the name in shutdown
        service.BusName.__del__ = lambda _: None
        yield self.bus.set_exit_on_disconnect(False)
        self.signal_receivers = set()


Generated by  Doxygen 1.6.0   Back to index