当前位置: 首页>>代码示例>>Python>>正文


Python Connection.signal_subscribe方法代码示例

本文整理汇总了Python中gstswitch.connection.Connection.signal_subscribe方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.signal_subscribe方法的具体用法?Python Connection.signal_subscribe怎么用?Python Connection.signal_subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gstswitch.connection.Connection的用法示例。


在下文中一共展示了Connection.signal_subscribe方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_handler_passed_to_gio

# 需要导入模块: from gstswitch.connection import Connection [as 别名]
# 或者: from gstswitch.connection.Connection import signal_subscribe [as 别名]
    def test_handler_passed_to_gio(self, monkeypatch):
        """Test if handler is correctly passed to Gio"""

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

        signal_subscribe_mock = Mock()
        monkeypatch.setattr(
            Gio.DBusConnection, 'signal_subscribe',
            signal_subscribe_mock)

        conn = Connection()
        conn.connect_dbus()
        test_cb = lambda: None
        conn.signal_subscribe(test_cb)

        # test that Gio's signal_subscribe method is called once
        # and passed the callback as-is
        signal_subscribe_mock.assert_called_once()

        # pylint does not recognize Mock.call_args as sequence and won't
        # allow us to unpack it. Disabling the warning because we know what
        # we're doing here

        # pylint: disable=unpacking-non-sequence
        args, _ = signal_subscribe_mock.call_args
        assert args[6] == test_cb
开发者ID:techman83,项目名称:gst-switch,代码行数:30,代码来源:test_connection_unit.py

示例2: test_handler_not_callable

# 需要导入模块: from gstswitch.connection import Connection [as 别名]
# 或者: from gstswitch.connection.Connection import signal_subscribe [as 别名]
    def test_handler_not_callable(self, monkeypatch):
        """Test if handler is not callable"""

        conn = Connection()
        test_cbs = ['', None, [], {}]
        for test_cb in test_cbs:
            with pytest.raises(ValueError):
                conn.signal_subscribe(test_cb)
开发者ID:techman83,项目名称:gst-switch,代码行数:10,代码来源:test_connection_unit.py

示例3: test_gio_error_is_converted

# 需要导入模块: from gstswitch.connection import Connection [as 别名]
# 或者: from gstswitch.connection.Connection import signal_subscribe [as 别名]
    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)
开发者ID:a740122,项目名称:gst-switch,代码行数:15,代码来源:test_connection_unit.py

示例4: test_gio_error_is_converted

# 需要导入模块: from gstswitch.connection import Connection [as 别名]
# 或者: from gstswitch.connection.Connection import signal_subscribe [as 别名]
    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()

        def test_cb():
            """ Dummy callback. """
            pass
        with pytest.raises(ConnectionError):
            conn.signal_subscribe(test_cb)
开发者ID:mithro,项目名称:gst-switch,代码行数:21,代码来源:test_connection_unit.py


注:本文中的gstswitch.connection.Connection.signal_subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。