class TestModelWNumLines10(unittest.TestCase): INPUT = ['{}\n'.format(n + 1) for n in range(10)] _SINGLE_NEG__MIDDLE = ArrEx(single(-5), [6]) _SINGLE_NEG__FIRST = ArrEx(single(-10), [1]) _TO_NEG = ArrEx(to_(-2), _int_list(1, 9)) _TO_POS = ArrEx(to_(4), _int_list(1, 4)) _TO_AFTER_MAX = ArrEx(to_(10 + 1), _int_list(1, 10)) _FROM_NEG = ArrEx(from_(-3), _int_list(8, 10)) _FROM_POS = ArrEx(from_(7), _int_list(7, 10)) _FROM_MAX = ArrEx(from_(10), [10]) _FROM_AFTER_MAX = ArrEx(from_(10 + 1), []) _FROM_TO__2_3 = ArrEx(from_to(2, 3), _int_list(2, 3)) _FROM_TO_NEG_NEG = ArrEx(from_to(-3, -2), _int_list(8, 9)) _FROM_TO_NEG_POS = ArrEx(from_to(-9, 3), _int_list(2, 3)) _FROM_TO_POS_NEG = ArrEx(from_to(7, -4), [7]) _FROM_TO_POS_POS = ArrEx(from_to(10, 12), [10]) RANGES_CASES = [ [_TO_NEG, _TO_POS], [_FROM_NEG, _FROM_POS], [_FROM_NEG, _TO_AFTER_MAX], [_FROM_TO_NEG_NEG, _FROM_TO_POS_NEG], [_FROM_TO_POS_POS, _FROM_TO_NEG_POS], [ _TO_NEG, _FROM_POS, _FROM_TO_NEG_POS, _FROM_TO_NEG_POS, _FROM_TO_POS_POS ], [_SINGLE_NEG__MIDDLE, _SINGLE_NEG__FIRST], ] CASES = [_case_of(case) for case in RANGES_CASES]
def _check_int_arg__wo_max_lines_from_iter( put: unittest.TestCase, limits: Limits, input_and_expected: InputAndExpected, ): _integration_check.check__w_max_as_lines_invocations__wo_max_lines_from_iter( put, [ranges.from_to(limits.lower, limits.upper).as_arg], input_and_expected)
def argument_cases(self) -> List[str]: return [ args.filter_line_nums(ranges.single(7).as_arg).as_str, args.filter_line_nums(ranges.single(-7).as_arg).as_str, args.filter_line_nums(ranges.to_(5).as_arg).as_str, args.filter_line_nums(ranges.to_(-5).as_arg).as_str, args.filter_line_nums(ranges.from_(5).as_arg).as_str, args.filter_line_nums(ranges.from_(-5).as_arg).as_str, args.filter_line_nums(ranges.from_to(5, 6).as_arg).as_str, args.filter_line_nums(ranges.from_to(-8, 8).as_arg).as_str, args.filter_line_nums(ranges.from_to(2, -2).as_arg).as_str, args.filter_line_nums(ranges.from_to(-5, -3).as_arg).as_str, args.filter_line_nums__multi( [ranges.single(5).as_arg, ranges.single(6).as_arg]).as_str, args.filter_line_nums__multi( [ranges.single(-5).as_arg, ranges.single(-6).as_arg]).as_str, ]
def _check_int_arg__w_access_of_all_model_properties( put: unittest.TestCase, limits: Limits, input_and_expected: InputAndExpected, ): the_range = ranges.from_to(limits.lower, limits.upper) _integration_check.check__w_access_of_all_model_properties( put, [the_range.as_arg], inp_exp__w_ext_deps(input_and_expected, the_range), )
def _check_int_arg__w_max_lines_from_iter( put: unittest.TestCase, limits: Limits, max_lines_accessed: int, input_and_expected: InputAndExpected, ): return _integration_check.check__w_max_lines_from_iter( put, [ranges.from_to(limits.lower, limits.upper).as_arg], max_lines_accessed, input_and_expected, )
class TestModelWNumLines0(unittest.TestCase): INPUT = [] RANGES_CASES = [ [to_(-2), to_(3)], [to_(-2), to_(-3)], [to_(-2), from_(2)], [to_(-2), from_(-2)], [to_(-3), from_to(2, -2)], [from_(-3), from_to(2, -2)], [from_(3), from_to(-4, -2)], [from_(3), from_to(2, 5)], ] def test_with_model_access__only_as_lines_is_used(self): checker = CheckerOfConstInput( self, self.INPUT, max_as_lines_invocations__when_only_checking_via_as_lines=2, ) for ranges in self.RANGES_CASES: with self.subTest([str(r) for r in ranges]): checker.check__wo_max_lines_from_iter( ranges, [], ) def test_with_model_access__check_all_model_properties(self): checker = CheckerOfConstInput( self, self.INPUT, max_as_lines_invocations__when_only_checking_via_as_lines=2, ) for ranges in self.RANGES_CASES: with self.subTest([str(r) for r in ranges]): checker.check__w_access_of_all_model_properties( ranges, [], )
class TestModelWNumLines1(unittest.TestCase): INPUT = ['1\n'] _SINGLE_NEG__1 = ArrEx(single(-1), [1]) _SINGLE_NEG__BEFORE = ArrEx(single(-2 - 1), []) _TO_NEG__BEFORE = ArrEx(to_(-2), []) _TO_NEG__1 = ArrEx(to_(-1), [1]) _TO_POS__AFTER = ArrEx(to_(2), [1]) _FROM_NEG__BEFORE = ArrEx(from_(-2), [1]) _FROM_NEG__1 = ArrEx(from_(-1), [1]) _FROM_POS__AFTER = ArrEx(from_(2), []) _FROM_TO__m1_m1 = ArrEx(from_to(-1, -1), [1]) _FROM_TO__m2_m1 = ArrEx(from_to(-2, -1), [1]) _FROM_TO__m1_2 = ArrEx(from_to(-1, 2), [1]) RANGES_CASES = [ [_SINGLE_NEG__1, _SINGLE_NEG__BEFORE], [_TO_NEG__BEFORE, _TO_NEG__BEFORE], [_TO_NEG__BEFORE, _TO_NEG__1], [_TO_NEG__BEFORE, _TO_POS__AFTER], [_FROM_NEG__BEFORE, _FROM_NEG__BEFORE], [_FROM_NEG__BEFORE, _FROM_NEG__1], [_FROM_NEG__BEFORE, _FROM_POS__AFTER], [_FROM_TO__m1_m1, _FROM_TO__m1_m1], [_FROM_TO__m1_m1, _FROM_TO__m1_2], [_FROM_TO__m2_m1, _FROM_TO__m1_2], [_SINGLE_NEG__1, _FROM_TO__m2_m1], [_SINGLE_NEG__1, _FROM_TO__m2_m1], [_SINGLE_NEG__BEFORE, _FROM_POS__AFTER], [_TO_NEG__BEFORE, _FROM_TO__m1_2, _SINGLE_NEG__1, _FROM_POS__AFTER], ] CASES = [_case_of(case) for case in RANGES_CASES]
Case.wo_upper_limit('two tail, min=1', [from_(1), from_(1)], lines_in_ranges__increasing=[1]), Case.wo_upper_limit('two tail, min=4', [from_(4), from_(5)], lines_in_ranges__increasing=[4]), Case.wo_upper_limit('two tail, min=9', [from_(13), from_(9)], lines_in_ranges__increasing=[9]), Case.wo_upper_limit('two tail, min=10', [from_(15), from_(10)], lines_in_ranges__increasing=[10]), Case.wo_upper_limit('two tail, min=11', [from_(13), from_(11)], lines_in_ranges__increasing=[11]), Case.wo_upper_limit('two tail, min=12', [from_(17), from_(12)], lines_in_ranges__increasing=[12]), ] CASES__BODY = [ Case.w_upper_limit('empty', [from_to(5, 4)], lines_in_ranges__increasing=[]), Case.w_upper_limit('1st', [from_to(0, 1)], lines_in_ranges__increasing=[1]), Case.w_upper_limit('no borders (merged)', [from_to(3, 5), from_to(6, 7)], lines_in_ranges__increasing=[3, 4, 5, 6, 7]), Case.w_upper_limit('no borders (not merged)', [from_to(3, 5), from_to(7, 8)], lines_in_ranges__increasing=[3, 4, 5, 7, 8]), Case.w_upper_limit('borders 1,2, 10 (not merged)', [from_to(1, 2), from_to(8, 10)], lines_in_ranges__increasing=[1, 2, 8, 9, 10]), Case.w_upper_limit('borders 10, 11 (merged)', [single(10), single(11)], lines_in_ranges__increasing=[10, 11]),