コード例 #1
0
    def runTest(self):
        # ARRANGE #

        path_symbol_name = 'the_path_symbol'
        file_matcher_symbol_name = 'the_file_matcher_symbol'

        expected_path_symbol_ref = asrt_sym_ref.symbol_usage_equals_data_type_symbol_reference(
            SymbolReference(path_symbol_name,
                            path_or_string_reference_restrictions(
                                EXPECTED_ACCEPTED_PATH_RELATIVITY_VARIANTS))
        )

        expected_file_matcher_ref = fm_references.is_reference_to_file_matcher(file_matcher_symbol_name)

        cases = [
            NEA('no symbols',
                asrt.matches_sequence([]),
                args.WithOptionalNegation(path_argument('plain-file-name'))
                ),
            NEA('path symbol',
                asrt.matches_sequence([
                    expected_path_symbol_ref,
                ]),
                args.WithOptionalNegation(symbol_path_argument(path_symbol_name))
                ),
            NEA('path symbol and file matcher symbol',
                asrt.matches_sequence([
                    expected_path_symbol_ref,
                    expected_file_matcher_ref,
                ]),
                args.WithOptionalNegation(symbol_path_argument(path_symbol_name),
                                          fm_args.SymbolReference(file_matcher_symbol_name))
                ),
        ]

        for case in cases:
            for expectation_type in ExpectationType:
                arguments = case.actual.get(expectation_type)
                source = remaining_source(str(arguments))
                with self.subTest(case=case.name,
                                  expectation_type=expectation_type):
                    # ACT #
                    instruction = sut.setup('the-instruction-name').parse(ARBITRARY_FS_LOCATION_INFO, source)
                    # ASSERT #
                    self.assertIsInstance(instruction, AssertPhaseInstruction)
                    case.expected.apply_without_message(self,
                                                        instruction.symbol_usages())
コード例 #2
0
    def runTest(self):
        # ARRANGE #

        for failing_file_matcher_case in failing_validation_cases__svh():
            failing_symbol_context = failing_file_matcher_case.value.symbol_context

            argument = args.CompleteInstructionArg(
                ExpectationType.POSITIVE,
                path_argument('ignored-file'),
                fm_args.SymbolReference(failing_symbol_context.name))

            with self.subTest(failing_file_matcher_case.name):
                # ACT & ASSERT #

                CHECKER.check(
                    self,
                    remaining_source(str(argument)),
                    ArrangementPostAct(
                        symbols=failing_symbol_context.symbol_table,
                    ),
                    instruction_check.expectation(
                        validation=failing_file_matcher_case.value.expectation,
                        symbol_usages=failing_symbol_context.references_assertion
                    ))
コード例 #3
0
 def file_argument(self, file_name: str) -> PathArgument:
     return path_args.path_argument(file_name, self.argument)
コード例 #4
0
 def path_argument_of_rel_name(self, file_name: str) -> PathArgument:
     return path_args.path_argument(file_name, self._cli_option.argument)
コード例 #5
0
 def path_argument(self) -> PathArgument:
     return args.path_argument(self.checked_dir_name)