当前位置: 首页>>代码示例>>Python>>正文


Python TestCase.subTest方法代码示例

本文整理汇总了Python中unittest.TestCase.subTest方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.subTest方法的具体用法?Python TestCase.subTest怎么用?Python TestCase.subTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.TestCase的用法示例。


在下文中一共展示了TestCase.subTest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: equivalent_source_variants_with_assertion

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import subTest [as 别名]
def equivalent_source_variants_with_assertion(put: unittest.TestCase,
                                              instruction_argument: str):
    """
    Yields a ParseSource, ValueAssertion
    """
    for following_lines, source_assertion in _SOURCE_VARIANT_TEST_CASES:
        with put.subTest(following_lines=repr(following_lines)):
            source = remaining_source(instruction_argument, following_lines)
            yield source, source_assertion
开发者ID:emilkarlen,项目名称:exactly,代码行数:11,代码来源:single_line_source_instruction_utils.py

示例2: equivalent_source_variants__with_source_check__multi_line

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import subTest [as 别名]
def equivalent_source_variants__with_source_check__multi_line(put: unittest.TestCase,
                                                              instruction_argument: Arguments):
    """
    Yields a ParseSource

    Checks that the first line of the source has been consumed.

    Assumes that the body of the loop parses using the given source.
    """
    for following_lines, source_assertion in _source_variant_test_cases__multi_line(instruction_argument.num_lines):
        with put.subTest(following_lines=repr(following_lines)):
            source = instruction_argument.followed_by_lines(following_lines).as_remaining_source
            yield source
            source_assertion.apply_with_message(put, source, 'source after parse')
开发者ID:emilkarlen,项目名称:exactly,代码行数:16,代码来源:single_line_source_instruction_utils.py

示例3: equivalent_source_variants__with_source_check__for_expression_parser

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import subTest [as 别名]
def equivalent_source_variants__with_source_check__for_expression_parser(
        put: unittest.TestCase,
        original_arguments: Arguments):
    """
    Yields a ParseSource

    Checks that the first line of the source has been consumed.

    Assumes that the body of the loop parses using the given source.
    """
    for following_arguments, source_assertion in _source_variants_with__for_expression_parser():
        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')
开发者ID:emilkarlen,项目名称:exactly,代码行数:19,代码来源:single_line_source_instruction_utils.py

示例4: check_parsing_of_program

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import subTest [as 别名]
def check_parsing_of_program(put: unittest.TestCase,
                             parser: Parser[ProgramResolver],
                             mk_argument_elements: Callable[[ArgumentElementRenderer], ArgumentElements],
                             program_case: ProgramNameCase,
                             argument_case: ArgumentsCase,
                             symbols: SymbolTable):
    with put.subTest(program=program_case.name,
                     arguments=argument_case.name):
        expected_references_assertion = asrt.matches_sequence(program_case.expected_symbol_references +
                                                              argument_case.expected_symbol_references)

        def expected_program(tcds: HomeAndSds) -> ValueAssertion[Program]:
            return asrt_pgm_val.matches_program(
                command=asrt_command.equals_system_program_command(
                    program=program_case.expected_resolved_value,
                    arguments=argument_case.expected_resolved_values(tcds)
                ),
                stdin=asrt_pgm_val.no_stdin(),
                transformer=asrt_line_transformer.is_identity_transformer()
            )

        expectation = asrt_resolver.matches_resolver_of_program(
            references=expected_references_assertion,
            resolved_program_value=asrt_dir_dep_val.matches_dir_dependent_value(
                resolving_dependencies=asrt.equals(argument_case.expected_dir_dependencies),
                resolved_value=expected_program,
            ),
            symbols=symbols
        )

        source = mk_argument_elements(cmd_line_args.system_program_cmd_line(program_case.source_element,
                                                                            argument_case.source_elements)
                                      ).as_remaining_source

        # ACT #

        actual = parser.parse(source)

        # ASSERT #

        expectation.apply_without_message(put, actual)
开发者ID:emilkarlen,项目名称:exactly,代码行数:43,代码来源:parse_system_program.py

示例5: check_many

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import subTest [as 别名]
def check_many(put: unittest.TestCase,
               arrangement: Arrangement,
               source_cases: List[SourceCase],
               expectation: ExpectationExceptPattern,
               option_cases: List[OptionCase],
               ):
    for source_case in source_cases:
        source_without_options = source_case.source
        for option_case in option_cases:
            expectation = Expectation(
                references=expectation.references,
                validation=expectation.validation,
                pattern=option_case.expectation,
                token_stream=source_case.source_assertion,
            )
            with put.subTest(source_case=source_case.name,
                             options=option_case.source_prefix):
                arguments_with_option = source_without_options.prepend_to_first_line(option_case.source_prefix)
                source_with_options = remaining_source_lines(arguments_with_option.lines)
                _check(put,
                       source_with_options,
                       arrangement,
                       expectation)
开发者ID:emilkarlen,项目名称:exactly,代码行数:25,代码来源:parse_regex.py

示例6: _test_cases

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import subTest [as 别名]
def _test_cases(put: unittest.TestCase, cases: Sequence[Case]):
    for case in cases:
        with put.subTest(case.name):
            _test_case(put, case)
开发者ID:emilkarlen,项目名称:exactly,代码行数:6,代码来源:parse_list.py


注:本文中的unittest.TestCase.subTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。