コード例 #1
0
    def run_predicate_with_reversed_result_should_work_properly(
            func_result: bool, expected_result: bool):
        def _function(*_, **__) -> Any:
            return func_result

        result = CommonFunctionUtils.run_predicate_with_reversed_result(
            _function)()
        CommonAssertionUtils.are_equal(result, expected_result)
コード例 #2
0
 def _enum_call_should_throw_when_value_not_found(value: Any):
     exception = CommonAssertionUtils.throws(lambda: TestEnum(value), value)
     CommonAssertionUtils.is_true(
         isinstance(exception, KeyError),
         message='Exception was not of type KeyError, it was type \'{}\''.
         format(type(exception)))
     CommonAssertionUtils.has_length(exception.args, 1)
     exception_message = exception.args[0]
     CommonAssertionUtils.are_equal(
         exception_message,
         'Value: \'{}\' not found within class \'TestEnum\''.format(value))
 def _s4cl_sim_types_are_close_enough(sim_type_one: CommonSimType,
                                      sim_type_two: CommonSimType,
                                      expected_result: bool) -> None:
     result = CommonSimTypeUtils().are_same_age_and_species(
         sim_type_one, sim_type_two)
     CommonAssertionUtils.are_equal(
         result, expected_result,
         'Sim Types were not considered similar when they should be. {} and {}'
         .format(sim_type_one.name, sim_type_two.name)
         if expected_result else
         'Sim Types were considered similar when they should not be. {} and {}'
         .format(sim_type_one.name, sim_type_two.name))
コード例 #4
0
    def run_predicates_as_one_should_work_properly(func_result_one: bool,
                                                   func_result_two: bool,
                                                   all_must_pass: bool,
                                                   expected_result: bool):
        def _function_one(*_, **__) -> Any:
            return func_result_one

        def _function_two(*_, **__) -> Any:
            return func_result_two

        result = CommonFunctionUtils.run_predicates_as_one(
            (_function_one, _function_two), all_must_pass=all_must_pass)()
        CommonAssertionUtils.are_equal(result, expected_result)
コード例 #5
0
 def _should_merge_dictionaries_allow_duplicates_false(dictionary_one: Dict[str, Any], dictionary_two: Dict[str, Any]) -> None:
     result_dict = CommonCollectionUtils.merge_dict(dictionary_one, dictionary_two, allow_duplicates_in_collections=False)
     CommonAssertionUtils.contains(result_dict, 'a', message=pformat(result_dict))
     CommonAssertionUtils.contains(result_dict, 'b', message=pformat(result_dict))
     CommonAssertionUtils.contains(result_dict, 'c', message=pformat(result_dict))
     CommonAssertionUtils.contains(result_dict, 'test_coll', message=pformat(result_dict))
     CommonAssertionUtils.contains(result_dict, 'test_other_coll', message=pformat(result_dict))
     a_val = result_dict['a']
     CommonAssertionUtils.are_equal(a_val, 5, message=pformat(result_dict))
     b_val = result_dict['b']
     CommonAssertionUtils.are_equal(b_val, 2, message=pformat(result_dict))
     c_val = result_dict['c']
     CommonAssertionUtils.are_equal(c_val, 6, message=pformat(result_dict))
     test_coll_val = result_dict['test_coll']
     CommonAssertionUtils.contains(test_coll_val, 1, message=pformat(result_dict))
     CommonAssertionUtils.contains(test_coll_val, 2, message=pformat(result_dict))
     CommonAssertionUtils.contains(test_coll_val, 3, message=pformat(result_dict))
     CommonAssertionUtils.contains(test_coll_val, 4, message=pformat(result_dict))
     CommonAssertionUtils.contains(test_coll_val, 5, message=pformat(result_dict))
     CommonAssertionUtils.contains(test_coll_val, 6, message=pformat(result_dict))
     count_of_test_val = 0
     for val in test_coll_val:
         if val == 3:
             count_of_test_val += 1
     CommonAssertionUtils.are_equal(count_of_test_val, 1, message='The number of 3s were not correct! {}'.format(pformat(result_dict)))
     test_other_coll_val = result_dict['test_other_coll']
     CommonAssertionUtils.contains(test_other_coll_val, 24, message=pformat(result_dict))
     CommonAssertionUtils.contains(test_other_coll_val, 25, message=pformat(result_dict))
コード例 #6
0
 def _function(normal_arg: str,
               value_one: str,
               normal_key_arg: str = None,
               key_value: str = None) -> Any:
     CommonAssertionUtils.are_equal(value_one, _additional_value)
     CommonAssertionUtils.are_equal(key_value,
                                    _additional_key_word_value)
     CommonAssertionUtils.are_equal(normal_arg, normal_val)
     CommonAssertionUtils.are_equal(normal_key_arg, normal_key_val)
     if normal_arg == normal_val and normal_key_arg == normal_key_val and value_one == _additional_value and key_value == _additional_key_word_value:
         return True
コード例 #7
0
 def _enum_should_be_gained_via_calling_the_enum_class_by_name(
         value: Any, expected_value):
     CommonAssertionUtils.are_equal(TestEnum(value), expected_value)
コード例 #8
0
 def _enum_should_have_value() -> None:
     CommonAssertionUtils.is_true(
         hasattr(TestEnum.TEST_VALUE_ONE, 'value'),
         message='Enum did not have attribute \'value\'')
     CommonAssertionUtils.are_equal(
         getattr(TestEnum.TEST_VALUE_ONE, 'value'), 1)
コード例 #9
0
 def enum_should_have_name():
     CommonAssertionUtils.is_true(
         hasattr(TestEnum.TEST_VALUE_ONE, 'name'),
         message='Enum did not have attribute \'name\'')
     CommonAssertionUtils.are_equal(
         getattr(TestEnum.TEST_VALUE_ONE, 'name'), 'TEST_VALUE_ONE')
コード例 #10
0
 def enum_should_convert_properly(enum_val, expected_value):
     CommonAssertionUtils.are_equal(int(enum_val), expected_value)
 def should_combine(items: List[int], combination_length: int,
                    expected_outcome: Set[Tuple[int]]):
     result = CommonCollectionUtils.create_possible_combinations(
         items, combination_length)
     CommonAssertionUtils.are_equal(result, expected_outcome)
コード例 #12
0
 def _enum_should_convert_float_properly(enum_val, expected_value) -> None:
     CommonAssertionUtils.are_equal(float(enum_val), expected_value)
コード例 #13
0
 def _enum_should_convert_string_properly(enum_val, expected_value) -> None:
     CommonAssertionUtils.are_equal(expected_value, str(enum_val))
 def _get_and_new_should_equal_same_instance() -> None:
     CommonAssertionUtils.are_equal(_TestService(), _TestService.get())
コード例 #15
0
 def _s4cl_determine_sim_type(species: CommonSpecies, age: CommonAge,
                              occult_type: CommonOccultType,
                              expected_sim_type: CommonSimType):
     result = CommonSimTypeUtils()._determine_sim_type(
         species, age, occult_type)
     CommonAssertionUtils.are_equal(result, expected_sim_type)