本文整理汇总了Python中healthnmon.tests.FakeLibvirt.libvirtError方法的典型用法代码示例。如果您正苦于以下问题:Python FakeLibvirt.libvirtError方法的具体用法?Python FakeLibvirt.libvirtError怎么用?Python FakeLibvirt.libvirtError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.tests.FakeLibvirt
的用法示例。
在下文中一共展示了FakeLibvirt.libvirtError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_broken_connection_remote
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import libvirtError [as 别名]
def test_broken_connection_remote(self):
libvirtError = libvirt.libvirtError('fake failure')
# libError = self.mox.CreateMockAnything()
# self.stubs.Set(libvirt.libvirtError, '__init__', libError)
# libError('fake failure').AndReturn(libvirtError)
capability = self.mox.CreateMockAnything()
self.stubs.Set(libvirt.virConnect, 'getCapabilities',
capability)
capability().AndRaise(libvirtError)
# self.mox.StubOutWithMock(libvirt.libvirtError, "get_error_domain")
#
# libvirt.libvirtError.get_error_code().AndReturn(error)
# libvirt.libvirtError.get_error_domain().AndReturn(domain)
self.mox.ReplayAll()
conn = connection.get_connection(False)
conn._wrapped_conn = self.fakeConn
try:
self.assertFalse(conn._test_connection())
except:
print 'over'
示例2: test_broken_connection_cover
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import libvirtError [as 别名]
def test_broken_connection_cover(self):
global libvirt
libvirt = libvirt = __import__('libvirt')
error = 38
domain = 13
conn = connection.get_connection(False)
# self.mox.StubOutWithMock(libvirt,'openReadOnly')
# libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
# conn._wrapped_conn=self.fakeConn
self.mox.StubOutWithMock(conn, '_wrapped_conn')
self.mox.StubOutWithMock(conn._wrapped_conn, 'getCapabilities')
self.mox.StubOutWithMock(libvirt.libvirtError, 'get_error_code')
self.mox.StubOutWithMock(libvirt.libvirtError,
'get_error_domain')
conn._wrapped_conn.getCapabilities().AndRaise(
FakeLibvirt.libvirtError('fake failure'
))
libvirt.libvirtError.get_error_code().MultipleTimes(). \
AndReturn(error)
libvirt.libvirtError.get_error_domain().MultipleTimes(). \
AndReturn(domain)
self.mox.ReplayAll()
try:
self.assertFalse(conn._test_connection())
except:
print 'error'
示例3: test_test_connection_exception
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import libvirtError [as 别名]
def test_test_connection_exception(self):
self.mox.StubOutWithMock(self.fakeConn, 'getCapabilities')
self.fakeConn.getCapabilities().AndRaise(libvirt.libvirtError())
self.mox.ReplayAll()
conn1 = connection.get_connection(True)
conn1._wrapped_conn = self.fakeConn
libvirt.VIR_ERR_SYSTEM_ERROR = 500
self.assertRaises(libvirt.libvirtError, conn1._test_connection)
self.mox.UnsetStubs()