コード例 #1
0
    def test_address_parsing(self):
        addresses = ('19 Long Lane, London EC1A 9PL', '11 Pilgrim St, London EC4V 6RN',
        '20-22 Great Titchfield Street London W1W 8BE',)

        reporter = GenericDiffReporterFactory().get('meld')
        verify_all_combinations(
            function_under_test, input_arguments=(addresses,), reporter=reporter
        )
コード例 #2
0
    def test_constrain(self):
        values = [n for n in range(-140, 141)]

        arg_combinations = (values,)
        func = lambda a: constrain(a, -125, 125)
        verify_all_combinations(
            func,
            arg_combinations,
            reporter=self.reporter)
コード例 #3
0
 def test_input_combinations_for_positive_interest_rates(self):
     principals = (Decimal('100.00'), Decimal('2000.00'), Decimal('3000.00'), )
     interest_rates = (Decimal('0.01'), Decimal('0.05'), Decimal('0.1'), )
     durations = (0, 1, 2, 3, 4, 5, 10, 20, 31, 52, 53)
     reporter = GenericDiffReporterFactory().get('meld')
     verify_all_combinations(
         get_weekly_repayment_amount,
         input_arguments=(principals, interest_rates, durations),
         reporter=reporter
     )
コード例 #4
0
    def test_mixer(self):
        x_axis_values = [n for n in range(-140, 141, 2)]
        y_axis_values = [n for n in range(-140, 141, 2)]

        arg_combinations = (x_axis_values, y_axis_values)
        func = lambda a, b: mixer(a, b)
        verify_all_combinations(
            func,
            arg_combinations,
            reporter=self.reporter)
コード例 #5
0
 def test_uses_user_specified_formatter_when_supplied(self):
     arg1_combinations = (1, 3)
     arg2_combinations = (2, 4)
     arg_combinations = (arg1_combinations, arg2_combinations)
     verify_all_combinations(
         self.func,
         arg_combinations,
         formatter=lambda args, output: "inputs=" + str(args) + ", outputs=" + str(output) + "\n",
         reporter=self.reporter
     )
コード例 #6
0
    def test_records_exception_message_when_function_under_test_throws_an_exception(self):
        class BackwardCompatibleException(Exception):
            """Exception with repr that's the same for pre 3.7 and 3.7+.

            Python3.7 got rid of the trailing comma in the `repr` of `BaseException`: https://bugs.python.org/issue30399
            """
            def __repr__(self):
                return 'Exception{}'.format(self.args)

        def function_that_raises_exceptions(*args):
            raise BackwardCompatibleException(args)

        arg1_combinations = (1, 3)
        arg2_combinations = (2, 4)
        arg_combinations = (arg1_combinations, arg2_combinations)
        verify_all_combinations(function_that_raises_exceptions, arg_combinations, reporter=self.reporter)
コード例 #7
0
    def test_process_abs_z_event(self):
        states = [n for n in range(-180, 181)]

        arg_combinations = (states,)
        func = lambda a: process_abs_z_event(a)
        verify_all_combinations(func, arg_combinations, reporter=self.reporter)
コード例 #8
0
 def test_for_func_accepting_three_args_and_combination_of_three_args(self):
     arg1_combinations = (1, 2, 3)
     arg2_combinations = (2, 4, 6)
     arg3_combinations = (10, 11, 12)
     arg_combinations = (arg1_combinations, arg2_combinations, arg3_combinations)
     verify_all_combinations(self.func, arg_combinations, reporter=self.reporter)
コード例 #9
0
 def test_when_arg_combinations_have_equal_lengths(self):
     arg1_combinations = (1, 3, 5, 7)
     arg2_combinations = (2, 4, 6)
     arg_combinations = (arg1_combinations, arg2_combinations)
     verify_all_combinations(self.func, arg_combinations, reporter=self.reporter)
コード例 #10
0
 def test_fails_for_mismatch_with_for_func_accepting_two_args_and_combination_of_two_args(self):
     arg1_combinations = (1, 3)
     arg2_combinations = (2, 4)
     arg_combinations = (arg1_combinations, arg2_combinations)
     with self.assertRaises(ApprovalException):
         verify_all_combinations(self.func, arg_combinations, reporter=self.reporter)
コード例 #11
0
 def test_passes_for_func_accepting_two_args_and_combination_of_one_arg(self):
     arg1_combinations = (1,)
     arg2_combinations = (2,)
     arg_combinations = (arg1_combinations, arg2_combinations)
     verify_all_combinations(self.func, arg_combinations, reporter=self.reporter)
コード例 #12
0
 def test_fails_for_mismatch_with_for_func_accepting_two_args_and_combination_of_one_arg(self):
     arg1_combinations = (1,)
     arg2_combinations = (2,)
     arg_combinations = (arg1_combinations, arg2_combinations)
     with self.assertRaises(ApprovalException):
         verify_all_combinations(self.func, arg_combinations, reporter=self.reporter)
コード例 #13
0
 def test_passes_for_func_accepting_one_arg_and_combination_of_two_args(self):
     arg1_combinations = (1, 2)
     all_args_combinations = (arg1_combinations,)
     verify_all_combinations(self.func, all_args_combinations, reporter=self.reporter)
コード例 #14
0
 def test_fails_for_mismatch_with_for_func_accepting_one_arg_and_combination_of_one_arg(self):
     arg1_combinations = (1,)
     all_args_combinations = (arg1_combinations,)
     with self.assertRaises(ApprovalException):
         verify_all_combinations(self.func, all_args_combinations, reporter=self.reporter)