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


Python unittest.FailTest方法代码示例

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


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

示例1: doNotFailOnNetworkError

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def doNotFailOnNetworkError(func):
    """
    A decorator which makes APIBuilder tests not fail because of intermittent
    network failures -- mamely, APIBuilder being unable to get the "object
    inventory" of other projects.

    @param func: The function to decorate.

    @return: A decorated function which won't fail if the object inventory
        fetching fails.
    """
    @functools.wraps(func)
    def wrapper(*a, **kw):
        try:
            func(*a, **kw)
        except FailTest as e:
            if e.args[0].startswith("'Failed to get object inventory from "):
                raise SkipTest(
                    ("This test is prone to intermittent network errors. "
                     "See ticket 8753. Exception was: {!r}").format(e))
            raise
    return wrapper 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:test_release.py

示例2: test_nonStringKeys

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def test_nonStringKeys(self):
        """
        L{dirdbm.DirDBM} operations only support string keys: other types
        should raise a L{TypeError}.
        """
        self.assertRaises(TypeError, self.dbm.__setitem__, 2, "3")
        try:
            self.assertRaises(TypeError, self.dbm.__setitem__, "2", 3)
        except unittest.FailTest:
            # dirdbm.Shelf.__setitem__ supports non-string values
            self.assertIsInstance(self.dbm, dirdbm.Shelf)
        self.assertRaises(TypeError, self.dbm.__getitem__, 2)
        self.assertRaises(TypeError, self.dbm.__delitem__, 2)
        self.assertRaises(TypeError, self.dbm.has_key, 2)
        self.assertRaises(TypeError, self.dbm.__contains__, 2)
        self.assertRaises(TypeError, self.dbm.getModificationTime, 2) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:test_dirdbm.py

示例3: testThreadedSynchronization

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def testThreadedSynchronization(self):
        o = TestObject()

        errors = []

        def callMethodLots():
            try:
                for i in range(1000):
                    o.aMethod()
            except AssertionError as e:
                errors.append(str(e))

        threads = []
        for x in range(5):
            t = threading.Thread(target=callMethodLots)
            threads.append(t)
            t.start()

        for t in threads:
            t.join()

        if errors:
            raise unittest.FailTest(errors) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:25,代码来源:test_threadable.py

示例4: test_nonStringKeys

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def test_nonStringKeys(self):
        """
        L{dirdbm.DirDBM} operations only support string keys: other types
        should raise a C{AssertionError}. This really ought to be a
        C{TypeError}, but it'll stay like this for backward compatibility.
        """
        self.assertRaises(AssertionError, self.dbm.__setitem__, 2, "3")
        try:
            self.assertRaises(AssertionError, self.dbm.__setitem__, "2", 3)
        except unittest.FailTest:
            # dirdbm.Shelf.__setitem__ supports non-string values
            self.assertIsInstance(self.dbm, dirdbm.Shelf)
        self.assertRaises(AssertionError, self.dbm.__getitem__, 2)
        self.assertRaises(AssertionError, self.dbm.__delitem__, 2)
        self.assertRaises(AssertionError, self.dbm.has_key, 2)
        self.assertRaises(AssertionError, self.dbm.__contains__, 2)
        self.assertRaises(AssertionError, self.dbm.getModificationTime, 2) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:test_dirdbm.py

示例5: setUp

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def setUp(self):
        return defer.fail(unittest.FailTest('i fail')) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:4,代码来源:detests.py

示例6: testRaises

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def testRaises(self):
        self.assertTrue(util.raises(ZeroDivisionError, divmod, 1, 0))
        self.assertFalse(util.raises(ZeroDivisionError, divmod, 0, 1))

        try:
            util.raises(TypeError, divmod, 1, 0)
        except ZeroDivisionError:
            pass
        else:
            raise unittest.FailTest("util.raises didn't raise when it should have") 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:test_util.py

示例7: test_skipsOnAssertionError

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def test_skipsOnAssertionError(self):
        """
        When the test raises L{FailTest} and the assertion failure starts with
        "'Failed to get object inventory from ", the test will be skipped
        instead.
        """
        @doNotFailOnNetworkError
        def inner():
            self.assertEqual("Failed to get object inventory from blah", "")

        try:
            inner()
        except Exception as e:
            self.assertIsInstance(e, SkipTest) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:test_release.py

示例8: test_doesNotSkipOnDifferentError

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def test_doesNotSkipOnDifferentError(self):
        """
        If there is a L{FailTest} that is not the intersphinx fetching error,
        it will be passed through.
        """
        @doNotFailOnNetworkError
        def inner():
            self.assertEqual("Error!!!!", "")

        try:
            inner()
        except Exception as e:
            self.assertIsInstance(e, FailTest) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:test_release.py

示例9: connectionLost

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def connectionLost(self, reason):
            if self.done:
                return
            if not hasattr(self, 'expectedLoseConnection'):
                raise unittest.FailTest(
                    'unexpectedly lost connection %s\n%s' % (self, reason))
            self.done = 1 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_ssh.py

示例10: receiveUnimplemented

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def receiveUnimplemented(self, seqID):
            raise unittest.FailTest('got unimplemented: seqid %s' % (seqID,))
            self.expectedLoseConnection = 1
            self.loseConnection() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:6,代码来源:test_ssh.py

示例11: ssh_USERAUTH_SUCCESS

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def ssh_USERAUTH_SUCCESS(self, packet):
            if not self.canSucceedPassword and self.canSucceedPublicKey:
                raise unittest.FailTest(
                    'got USERAUTH_SUCCESS before password and publickey')
            userauth.SSHUserAuthClient.ssh_USERAUTH_SUCCESS(self, packet) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:test_ssh.py

示例12: test_newStyleClassesOnly

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def test_newStyleClassesOnly(self):
        """
        Test that C{self.module} has no old-style classes in it.
        """
        try:
            module = namedAny(self.module)
        except ImportError as e:
            raise unittest.SkipTest("Not importable: {}".format(e))

        oldStyleClasses = []

        for name, val in inspect.getmembers(module):
            if hasattr(val, "__module__") \
               and val.__module__ == self.module:
                if isinstance(val, types.ClassType):
                    oldStyleClasses.append(fullyQualifiedName(val))

        if oldStyleClasses:

            self.todo = "Not all classes are made new-style yet. See #8243."

            for x in forbiddenModules:
                if self.module.startswith(x):
                    delattr(self, "todo")

            raise unittest.FailTest(
                "Old-style classes in {module}: {val}".format(
                    module=self.module,
                    val=", ".join(oldStyleClasses))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:31,代码来源:test_nooldstyle.py

示例13: testRaises

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def testRaises(self):
        self.failUnless(util.raises(ZeroDivisionError, divmod, 1, 0))
        self.failIf(util.raises(ZeroDivisionError, divmod, 0, 1))

        try:
            util.raises(TypeError, divmod, 1, 0)
        except ZeroDivisionError:
            pass
        else:
            raise unittest.FailTest, "util.raises didn't raise when it should have" 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:12,代码来源:test_util.py

示例14: _cbRoundRobinBackoff

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def _cbRoundRobinBackoff(self, result):
        raise unittest.FailTest("Lookup address succeeded, should have timed out") 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:4,代码来源:test_names.py

示例15: test_create

# 需要导入模块: from twisted.trial import unittest [as 别名]
# 或者: from twisted.trial.unittest import FailTest [as 别名]
def test_create(self):
        """
        Test the creation of an epoll object.
        """
        try:
            p = _epoll.epoll(16)
        except OSError, e:
            raise unittest.FailTest(str(e)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:10,代码来源:test_epoll.py


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