Example #1
0
 def call_sync(self, bus_name, object_path, interface_name, method_name,
               parameters, reply_type, flags, timeout_msec, cancellable):
     """Mock of call_sync method,
     raises GLib.GError if interface_name invalid"""
     if interface_name == "info.duzy.gst.switch.SwitchControllerInterface":
         return self.return_result
     else:
         raise GLib.GError('{0}: Test Failed'.format(self.method))
 def on_enough_data_app_source(self, src):
     try:
         self._app_source.pause_frames()
     except Exception as error:
         self._logger.error("Error on Pipeline {id}: Error in App Source: {err}".format(
             id=self.identifier, err=error))
         src.post_message(Gst.Message.new_error(src, GLib.GError(),
                                                "AppSource: {}".format(str(error))))
    def test_gio_error_is_converted(self, monkeypatch):
        """Test if handler is correctly passed to Gio"""

        monkeypatch.setattr(Gio.DBusConnection, 'new_for_address_sync',
                            Mock(return_value=Gio.DBusConnection()))

        monkeypatch.setattr(Gio.DBusConnection, 'signal_subscribe',
                            Mock(side_effect=GLib.GError('Boom!')))

        conn = Connection()
        conn.connect_dbus()
        test_cb = Mock()

        with pytest.raises(ConnectionError):
            conn.signal_subscribe(test_cb)
Example #4
0
def callback(directory, result, path):
    global count

    GLib.idle_add(lazy_list_directory)
    try:
        enumerator = directory.enumerate_children_finish(result)
    except GLib.GError, e:
        # Permission denied
        if e.code == 14:
            return

        # File not found
        if e.code ==1:
            return

        raise GLib.GError(e)
Example #5
0
 def test_error_init(self):
     error = GLib.GError("foo")
     self.assertTrue("foo" in str(error))