Python unittest2 模块,expectedFailure() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用unittest2.expectedFailure()

项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def test_old_testresult(self):
        class Test(unittest2.TestCase):
            def testSkip(self):
                self.skipTest('foobar')
            @unittest2.expectedFailure
            def testExpectedFail(self):
                raise TypeError
            @unittest2.expectedFailure
            def testUnexpectedSuccess(self):
                pass

        for test_name, should_pass in (('testSkip', True),
                                       ('testExpectedFail', True),
                                       ('testUnexpectedSuccess', False)):
            test = Test(test_name)
            self.assertOldResultWarning(test, int(not should_pass))
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def test_expected_failure_subtests(self):
        # A failure in any subtest counts as the expected failure of the
        # whole test.
        class Foo(unittest.TestCase):
            @unittest.expectedFailure
            def test_die(self):
                with self.subTest():
                    # This one succeeds
                    pass
                with self.subTest():
                    self.fail("help me!")
                with self.subTest():
                    # This one doesn't get executed
                    self.fail("shouldn't come here")
        events = []
        result = LoggingResult(events)
        test = Foo("test_die")
        test.run(result)
        self.assertEqual(events,
                         ['startTest', 'addSubTestSuccess',
                          'addExpectedFailure', 'stopTest'])
        self.assertEqual(len(result.expectedFailures), 1)
        self.assertIs(result.expectedFailures[0][0], test)
        self.assertTrue(result.wasSuccessful())
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def test_unexpected_success_subtests(self):
        # Success in all subtests counts as the unexpected success of
        # the whole test.
        class Foo(unittest.TestCase):
            @unittest.expectedFailure
            def test_die(self):
                with self.subTest():
                    # This one succeeds
                    pass
                with self.subTest():
                    # So does this one
                    pass
        events = []
        result = LoggingResult(events)
        test = Foo("test_die")
        test.run(result)
        self.assertEqual(events,
                         ['startTest',
                          'addSubTestSuccess', 'addSubTestSuccess',
                          'addUnexpectedSuccess', 'stopTest'])
        self.assertFalse(result.failures)
        self.assertEqual(result.unexpectedSuccesses, [test])
        self.assertFalse(result.wasSuccessful())
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def test_expected_failure(self):
        class Foo(unittest2.TestCase):
            @unittest2.expectedFailure
            def test_die(self):
                self.fail("help me!")
        events = []
        result = LoggingResult(events)
        test = Foo("test_die")
        test.run(result)
        self.assertEqual(events,
                         ['startTest', 'addExpectedFailure', 'stopTest'])
        self.assertEqual(result.expectedFailures[0][0], test)
        self.assertTrue(result.wasSuccessful())
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
def test_unexpected_success(self):
        class Foo(unittest2.TestCase):
            @unittest2.expectedFailure
            def test_die(self):
                pass
        events = []
        result = LoggingResult(events)
        test = Foo("test_die")
        test.run(result)
        self.assertEqual(events,
                         ['startTest', 'addUnexpectedSuccess', 'stopTest'])
        self.assertFalse(result.failures)
        self.assertEqual(result.unexpectedSuccesses, [test])
        self.assertFalse(result.wasSuccessful())
项目:py2rb    作者:naitoh    | 项目源码 | 文件源码
def compile_and_run_file_failing_test(*a, **k):
    """Turn a test to a failing test"""
    _class = compile_and_run_file_test(*a, **k)

    class FailingTest(_class):
        """Failing test"""
        @unittest.expectedFailure
        def runTest(self):
            return super(FailingTest, self).runTest()

    return FailingTest
项目:hakkuframework    作者:4shadoww    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)
项目:hakkuframework    作者:4shadoww    | 项目源码 | 文件源码
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func)
项目:hakkuframework    作者:4shadoww    | 项目源码 | 文件源码
def expectedFailurePY27(func):
    if not PY27:
        return func
    return unittest.expectedFailure(func)
项目:hakkuframework    作者:4shadoww    | 项目源码 | 文件源码
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3:
项目:hakkuframework    作者:4shadoww    | 项目源码 | 文件源码
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f
项目:packaging    作者:blockstack    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)
项目:packaging    作者:blockstack    | 项目源码 | 文件源码
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func)
项目:packaging    作者:blockstack    | 项目源码 | 文件源码
def expectedFailurePY27(func):
    if not PY27:
        return func
    return unittest.expectedFailure(func)
项目:packaging    作者:blockstack    | 项目源码 | 文件源码
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3:
项目:packaging    作者:blockstack    | 项目源码 | 文件源码
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func)
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
def expectedFailurePY27(func):
    if not PY27:
        return func
    return unittest.expectedFailure(func)
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3:
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f
项目:FightstickDisplay    作者:calexil    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)
项目:FightstickDisplay    作者:calexil    | 项目源码 | 文件源码
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func)
项目:FightstickDisplay    作者:calexil    | 项目源码 | 文件源码
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3:
项目:FightstickDisplay    作者:calexil    | 项目源码 | 文件源码
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f
项目:cryptogram    作者:xinmingzhang    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)
项目:cryptogram    作者:xinmingzhang    | 项目源码 | 文件源码
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func)
项目:cryptogram    作者:xinmingzhang    | 项目源码 | 文件源码
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3:
项目:cryptogram    作者:xinmingzhang    | 项目源码 | 文件源码
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func)
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def expectedFailurePY27(func):
    if not PY27:
        return func
    return unittest.expectedFailure(func)
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3:
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f
项目:UMOG    作者:hsab    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)
项目:UMOG    作者:hsab    | 项目源码 | 文件源码
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func)
项目:UMOG    作者:hsab    | 项目源码 | 文件源码
def expectedFailurePY27(func):
    if not PY27:
        return func
    return unittest.expectedFailure(func)
项目:UMOG    作者:hsab    | 项目源码 | 文件源码
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3:
项目:UMOG    作者:hsab    | 项目源码 | 文件源码
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func)
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def expectedFailurePY27(func):
    if not PY27:
        return func
    return unittest.expectedFailure(func)
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3:
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f
项目:beepboop    作者:nicolehe    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)
项目:beepboop    作者:nicolehe    | 项目源码 | 文件源码
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func)
项目:beepboop    作者:nicolehe    | 项目源码 | 文件源码
def expectedFailurePY27(func):
    if not PY27:
        return func
    return unittest.expectedFailure(func)
项目:beepboop    作者:nicolehe    | 项目源码 | 文件源码
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3:
项目:beepboop    作者:nicolehe    | 项目源码 | 文件源码
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f
项目:hackathon    作者:vertica    | 项目源码 | 文件源码
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func)