本文整理汇总了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
示例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
示例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()
示例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)
示例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)
示例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()
示例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()
示例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()