Beispiel #1
0
def equivalent_source_variants__for_expression_parser_2(
    original_arguments: Arguments,
) -> List[NEA[Assertion[ParseSource], ParseSource]]:
    num_lines = original_arguments.num_lines
    return [
        NEA(name='additional_arguments_on_same_line={}, additional_lines={}'.
            format(
                repr(following_arguments.first_line),
                repr(following_arguments.following_lines),
            ),
            expected=source_assertion,
            actual=original_arguments.last_line_followed_by(
                following_arguments,
                first_line_separator='').as_remaining_source)
        for following_arguments, source_assertion in
        _source_variants_with__for_expression_parser(num_lines)
    ]
Beispiel #2
0
def equivalent_source_variants__for_expression_parser(
    put: unittest.TestCase,
    original_arguments: Arguments,
) -> Iterator[ParseSource]:
    """
    Assumes that the body of the loop parses using the given source.
    """
    for following_arguments, source_assertion in _source_variants_with__for_expression_parser(
            original_arguments.num_lines):
        with put.subTest(additional_arguments_on_same_line=repr(
                following_arguments.first_line),
                         additional_lines=repr(
                             following_arguments.following_lines)):
            source = original_arguments.last_line_followed_by(
                following_arguments,
                first_line_separator='').as_remaining_source
            yield source
            source_assertion.apply_with_message(put, source,
                                                'source after parse')