Exemplo n.º 1
0
    def _doTest(self, maybe_not: ExpectationTypeConfigForNoneIsSuccess):
        expected_content_line_template = 'expected content line, with {symbol} ref'

        def expected_content(symbol_content: str) -> str:
            return expected_content_line_template.format(symbol=symbol_content)

        symbol = StringConstantSymbolContext('symbol_name', 'the symbol value')
        self._check(
            test_configuration.source_for(
                args('{maybe_not} {equals} <<EOF',
                     maybe_not=maybe_not.nothing__if_positive__not_option__if_negative),
                [expected_content(symbol.name__sym_ref_syntax),
                 'EOF',
                 'following line']),
            model_constructor.of_str(self, lines_content([expected_content(symbol.str_value)])),
            arrangement_w_tcds(
                post_population_action=MK_SUB_DIR_OF_ACT_AND_MAKE_IT_CURRENT_DIRECTORY,
                symbols=symbol.symbol_table),
            Expectation(
                ParseExpectation(
                    source=asrt_source.is_at_end_of_line(3),
                    symbol_references=asrt.matches_sequence([
                        symbol.reference_assertion__w_str_rendering
                    ]),
                ),
                ExecutionExpectation(
                    main_result=maybe_not.pass__if_positive__fail__if_negative,
                ),
            ),
        )
Exemplo n.º 2
0
 def _check_variants_with_expectation_type(
         self,
         args_variant_constructor: InstructionArgumentsVariantConstructor):
     for expectation_type in ExpectationType:
         with self.subTest(expectation_type=expectation_type):
             args_variant = args_variant_constructor.construct(
                 expectation_type)
             with self.assertRaises(
                     SingleInstructionInvalidArgumentException):
                 sut.parsers().full.parse(
                     test_configuration.source_for(args_variant))
Exemplo n.º 3
0
 def _check_variants_with_expectation_type_and_any_or_every(
     self, args_variant_constructor: tr.
     InstructionArgumentsConstructorForExpTypeAndQuantifier):
     for expectation_type in ExpectationType:
         for quantifier in Quantifier:
             with self.subTest(expectation_type=expectation_type,
                               any_or_every_keyword=quantifier):
                 args_variant = args_variant_constructor.construct(
                     expectation_type, quantifier)
                 with self.assertRaises(
                         SingleInstructionInvalidArgumentException):
                     sut.parsers().full.parse(
                         test_configuration.source_for(args_variant))
Exemplo n.º 4
0
 def _doTest(self, maybe_not: ExpectationTypeConfigForNoneIsSuccess):
     parser = sut.parsers().full
     for maybe_with_transformer_option in TRANSFORMER_OPTION_ALTERNATIVES:
         for maybe_full_match in FULL_MATCH_OPTION_ALTERNATIVES:
             with self.subTest(maybe_with_transformer_option=maybe_with_transformer_option,
                               maybe_full_match=maybe_full_match):
                 source = test_configuration.source_for(
                     args('{maybe_with_transformer_option} {maybe_not} {matches} {maybe_full_match}',
                          maybe_with_transformer_option=maybe_with_transformer_option,
                          maybe_full_match=maybe_full_match,
                          maybe_not=maybe_not.nothing__if_positive__not_option__if_negative),
                 )
                 with self.assertRaises(SingleInstructionInvalidArgumentException):
                     parser.parse(source)
Exemplo n.º 5
0
 def _doTest(self, maybe_not: ExpectationTypeConfigForNoneIsSuccess):
     parser = sut.parsers().full
     for maybe_with_transformer_option in TRANSFORMER_OPTION_ALTERNATIVES:
         with self.subTest(maybe_with_transformer_option=maybe_with_transformer_option):
             source = test_configuration.source_for(
                 args('{maybe_with_transformer_option} {maybe_not}',
                      maybe_with_transformer_option=maybe_with_transformer_option,
                      maybe_not=maybe_not.nothing__if_positive__not_option__if_negative),
             )
             with self.assertRaises(SingleInstructionInvalidArgumentException) as cm:
                 parser.parse(source)
             assert_is_single_instruction_invalid_argument_exception().apply_with_message(
                 self,
                 cm.exception,
                 'exception from parser'
             )
Exemplo n.º 6
0
 def _doTest(self, maybe_not: ExpectationTypeConfigForNoneIsSuccess):
     self._check(
         test_configuration.source_for(
             args('{maybe_not} {equals} <<EOF',
                  maybe_not=maybe_not.nothing__if_positive__not_option__if_negative),
             ['expected content line',
              'EOF']),
         model_constructor.of_str(self, lines_content(['expected content line'])),
         arrangement_w_tcds(
             post_population_action=MK_SUB_DIR_OF_ACT_AND_MAKE_IT_CURRENT_DIRECTORY),
         Expectation(
             ParseExpectation(
                 source=asrt_source.is_at_end_of_line(3),
             ),
             ExecutionExpectation(
                 main_result=maybe_not.pass__if_positive__fail__if_negative,
             ),
         ),
     )