Exemplo n.º 1
0
    def test_class_teardown_counted_as_failure_after_limit_reached(self):
        assert_equal(self.server.failure_count, 0)
        get_test(self.server, 'runner')

        # The following behavior is bad because it doesn't allow clients to
        # report class_teardown failures (which they are contractually
        # obligated to run regardless of any failure limit). See
        # https://github.com/Yelp/Testify/issues/120 for ideas about how to fix
        # this.
        #
        # For now, we write this test to pin down the existing behavior and
        # notice if it changes.
        test_case_name = self.dummy_test_case.__name__
        assert_raises_and_contains(
            ValueError,
            '%s not checked out.' % test_case_name,
            self.run_test,
            'runner',
        )
        # Verify that only N failing tests are run, where N is the server's
        # failure_limit.
        #
        # Once issue #120 is fixed, the failure count should (probably) be
        # TEST_RUNNER_SERVER_FAILURE_LIMIT + CLASS_TEARDOWN_FAILURES.
        assert_equal(self.server.failure_count,
                     self.TEST_RUNNER_SERVER_FAILURE_LIMIT)
Exemplo n.º 2
0
    def test_class_teardown_counted_as_failure_after_limit_reached(self):
        assert_equal(self.server.failure_count, 0)
        get_test(self.server, 'runner')

        # The following behavior is bad because it doesn't allow clients to
        # report class_teardown failures (which they are contractually
        # obligated to run regardless of any failure limit). See
        # https://github.com/Yelp/Testify/issues/120 for ideas about how to fix
        # this.
        #
        # For now, we write this test to pin down the existing behavior and
        # notice if it changes.
        test_case_name = self.dummy_test_case.__name__
        assert_raises_and_contains(
            ValueError,
            '%s not checked out.' % test_case_name,
            self.run_test,
            'runner',
        )
        # Verify that only N failing tests are run, where N is the server's
        # failure_limit.
        #
        # Once issue #120 is fixed, the failure count should (probably) be
        # TEST_RUNNER_SERVER_FAILURE_LIMIT + CLASS_TEARDOWN_FAILURES.
        assert_equal(self.server.failure_count, self.TEST_RUNNER_SERVER_FAILURE_LIMIT)
Exemplo n.º 3
0
 def test_methods_are_not_run_after_failure_limit_reached(self):
     assert_equal(self.server.failure_count, 0)
     get_test(self.server, 'runner')
     assert_raises_and_contains(
         ValueError,
         'FailureLimitTestCase not checked out.',
         self.run_test,
         'runner',
     )
     # Verify that only N failing tests are run, where N is the server's
     # failure_limit.
     assert_equal(self.server.failure_count, self.TEST_RUNNER_SERVER_FAILURE_LIMIT)
Exemplo n.º 4
0
 def test_methods_are_not_run_after_failure_limit_reached(self):
     assert_equal(self.server.failure_count, 0)
     get_test(self.server, 'runner')
     assert_raises_and_contains(
         ValueError,
         'FailureLimitTestCase not checked out.',
         self.run_test,
         'runner',
     )
     # Verify that only N failing tests are run, where N is the server's
     # failure_limit.
     assert_equal(self.server.failure_count, self.TEST_RUNNER_SERVER_FAILURE_LIMIT)
Exemplo n.º 5
0
def run_exception_test(imap_ordered_or_unordered):
    """
    Checks that exceptions are re-thrown, for either imap_unordered or imap_ordered.

    :param imap_ordered_or_unordered:
        either vimap.ext.sugar.imap_unordered or ...imap_ordered
    """
    def fcn(x):
        if x:
            raise ValueError("Bad value: {0}".format(x))
        return x

    with mock.patch.object(vimap.exception_handling,
                           'print_exception',
                           autospec=True) as mock_print_exception:
        T.assert_raises_and_contains(
            vimap.exception_handling.WorkerException,
            ("ValueError: Bad value: 3", ),
            lambda: tuple(imap_ordered_or_unordered(fcn, [False, 3, 0])))
        T.assert_equal(mock_print_exception.called, True)
Exemplo n.º 6
0
def run_exception_test(imap_ordered_or_unordered):
    """
    Checks that exceptions are re-thrown, for either imap_unordered or imap_ordered.

    :param imap_ordered_or_unordered:
        either vimap.ext.sugar.imap_unordered or ...imap_ordered
    """
    def fcn(x):
        if x:
            raise ValueError("Bad value: {0}".format(x))
        return x

    with mock.patch.object(
        vimap.exception_handling,
        'print_exception',
        autospec=True
    ) as mock_print_exception:
        T.assert_raises_and_contains(
            vimap.exception_handling.WorkerException,
            ("ValueError: Bad value: 3",),
            lambda: tuple(imap_ordered_or_unordered(fcn, [False, 3, 0]))
        )
        T.assert_equal(mock_print_exception.called, True)
Exemplo n.º 7
0
 def test_reraise(self):
     testify.assert_raises_and_contains(
         exception_handling.WorkerException,
         ("ValueError: hi", "Traceback:\n", "in get_ec"),
         lambda: self.get_ec().reraise())
Exemplo n.º 8
0
 def test_reraise(self):
     testify.assert_raises_and_contains(
         exception_handling.WorkerException,
         ("ValueError: hi", "Traceback:\n", "in get_ec"),
         lambda: self.get_ec().reraise()
     )