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


Python FakeLibvirt.libvirtError方法代码示例

本文整理汇总了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'
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:28,代码来源:test_libvirt_connection.py

示例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'
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:33,代码来源:test_libvirt_connection_import.py

示例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()
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:11,代码来源:test_libvirt_connection.py


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