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


Python Connection.connect_dbus方法代码示例

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


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

示例1: test_handler_passed_to_gio

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

# 需要导入模块: from gstswitch.connection import Connection [as 别名]
# 或者: from gstswitch.connection.Connection import connect_dbus [as 别名]
 def test_mock2(self, monkeypatch):
     """Test GLib.GError exception"""
     monkeypatch.setattr(
         Gio.DBusConnection, 'new_for_address_sync',
         Mock(return_value=1))
     conn = Connection()
     conn.connect_dbus()
     assert conn.connection is not None
开发者ID:techman83,项目名称:gst-switch,代码行数:10,代码来源:test_connection_unit.py

示例3: test_mock1

# 需要导入模块: from gstswitch.connection import Connection [as 别名]
# 或者: from gstswitch.connection.Connection import connect_dbus [as 别名]
 def test_mock1(self, monkeypatch):
     """Test GLib.GError exception"""
     monkeypatch.setattr(
         Gio.DBusConnection,
         'new_for_address_sync',
         Mock(side_effect=GLib.GError))
     conn = Connection()
     with pytest.raises(ConnectionError):
         conn.connect_dbus()
开发者ID:techman83,项目名称:gst-switch,代码行数:11,代码来源:test_connection_unit.py

示例4: test_gio_error_is_converted

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

示例5: test_gio_error_is_converted

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

示例6: test_bad_address3

# 需要导入模块: from gstswitch.connection import Connection [as 别名]
# 或者: from gstswitch.connection.Connection import connect_dbus [as 别名]
 def test_bad_address3(self):
     """Test if wrong address is given - 3"""
     address = 'unix:path'
     conn = Connection(address=address)
     with pytest.raises(ConnectionError):
         conn.connect_dbus()
开发者ID:techman83,项目名称:gst-switch,代码行数:8,代码来源:test_connection_unit.py

示例7: test_bad_address2

# 需要导入模块: from gstswitch.connection import Connection [as 别名]
# 或者: from gstswitch.connection.Connection import connect_dbus [as 别名]
 def test_bad_address2(self):
     """Test if wrong address is given - 2"""
     address = 'unix:temp=gstswitch'
     conn = Connection(address=address)
     with pytest.raises(ConnectionError):
         conn.connect_dbus()
开发者ID:techman83,项目名称:gst-switch,代码行数:8,代码来源:test_connection_unit.py

示例8: test_bad_address

# 需要导入模块: from gstswitch.connection import Connection [as 别名]
# 或者: from gstswitch.connection.Connection import connect_dbus [as 别名]
 def test_bad_address(self):
     """Test if wrong address is given - 1"""
     address = "unix:path=gstswitch"
     conn = Connection(address=address)
     with pytest.raises(ConnectionError):
         conn.connect_dbus()
开发者ID:a740122,项目名称:gst-switch,代码行数:8,代码来源:test_connection_unit.py


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