示例#1
0
    def _test_skip_helper(self,
                          raise_exception=True,
                          expected_to_skip=True,
                          **decorator_args):
        fail_test_reason = "test_bar failed"

        class TestFoo(test.BaseTestCase):
            @decorators.unstable_test(**decorator_args)
            def test_bar(self):
                if raise_exception:
                    raise Exception(fail_test_reason)
                else:
                    return 0

        t = TestFoo('test_bar')
        if expected_to_skip:
            e = self.assertRaises(testtools.TestCase.skipException, t.test_bar)
            bug = decorator_args['bug']
            bug_type = decorator_args.get('bug_type', 'launchpad')
            self.assertRegex(
                str(e),
                r'Marked as unstable and skipped because of bug\: %s.*, '
                'failure was: %s' %
                (decorators._get_bug_url(bug, bug_type), fail_test_reason))
        else:
            # assert that test_bar returned 0
            self.assertEqual(TestFoo('test_bar').test_bar(), 0)
示例#2
0
    def _test_skip_helper(self, raise_exception=True, expected_to_skip=True,
                          **decorator_args):
        fail_test_reason = "test_bar failed"

        class TestFoo(test.BaseTestCase):

            @decorators.unstable_test(**decorator_args)
            def test_bar(self):
                if raise_exception:
                    raise Exception(fail_test_reason)
                else:
                    return 0

        t = TestFoo('test_bar')
        if expected_to_skip:
            e = self.assertRaises(testtools.TestCase.skipException, t.test_bar)
            bug = decorator_args['bug']
            bug_type = decorator_args.get('bug_type', 'launchpad')
            self.assertRegex(
                str(e),
                r'Marked as unstable and skipped because of bug\: %s.*, '
                'failure was: %s' % (decorators._get_bug_url(bug, bug_type),
                                     fail_test_reason)
            )
        else:
            # assert that test_bar returned 0
            self.assertEqual(TestFoo('test_bar').test_bar(), 0)
示例#3
0
    def _test_skip_because_helper(self,
                                  expected_to_skip=True,
                                  **decorator_args):
        class TestFoo(test.BaseTestCase):
            _interface = 'json'

            @decorators.skip_because(**decorator_args)
            def test_bar(self):
                return 0

        t = TestFoo('test_bar')
        if expected_to_skip:
            e = self.assertRaises(testtools.TestCase.skipException, t.test_bar)
            bug = decorator_args['bug']
            bug_type = decorator_args.get('bug_type', 'launchpad')
            self.assertRegex(
                str(e), r'Skipped until bug\: %s.*' %
                decorators._get_bug_url(bug, bug_type))
        else:
            # assert that test_bar returned 0
            self.assertEqual(TestFoo('test_bar').test_bar(), 0)
示例#4
0
    def _test_skip_helper(self, raise_exception=True, expected_to_skip=True,
                          **decorator_args):
        class TestFoo(test.BaseTestCase):
            _interface = 'json'

            @decorators.skip_because(**decorator_args)
            def test_bar(self):
                return 0

        t = TestFoo('test_bar')
        if expected_to_skip:
            e = self.assertRaises(testtools.TestCase.skipException, t.test_bar)
            bug = decorator_args['bug']
            bug_type = decorator_args.get('bug_type', 'launchpad')
            self.assertRegex(
                str(e),
                r'Skipped until bug\: %s.*' % decorators._get_bug_url(
                    bug, bug_type)
            )
        else:
            # assert that test_bar returned 0
            self.assertEqual(TestFoo('test_bar').test_bar(), 0)