예제 #1
0
 def is_section_item(self,
                     put: unittest.TestCase,
                     value,
                     message_builder: asrt.MessageBuilder = asrt.MessageBuilder()):
     asrt.IsInstance(doc.SectionItem).apply(put, value, message_builder)
     assert isinstance(value, doc.SectionItem)
     asrt.sub_component('header',
                        doc.SectionItem.header.fget,
                        is_text
                        ).apply(put, value, message_builder)
     asrt.sub_component('tags',
                        doc.SectionItem.tags.fget,
                        asrt.is_instance_with(set,
                                              asrt.on_transformed(list,
                                                                  asrt.is_sequence_of(asrt.is_instance(str)))
                                              )
                        ).apply(put, value, message_builder)
     asrt.sub_component('target',
                        doc.SectionItem.target.fget,
                        asrt.is_instance(core.CrossReferenceTarget)),
     if isinstance(value, doc.Article):
         is_article_contents.apply(put, value.contents,
                                   message_builder.for_sub_component('article_contents'))
     elif isinstance(value, doc.Section):
         is_section_contents.apply(put, value.contents,
                                   message_builder.for_sub_component('section_contents'))
     else:
         asrt.fail('Not a {}: {}'.format(str(doc.SectionItem), str(value)))
예제 #2
0
 def test_fail_due_to_assertion_on_instruction_environment(self):
     self._check_source_and_exe_variants__failing_assertions(
         PARSER_THAT_GIVES_SUCCESSFUL_INSTRUCTION,
         Arrangement.phase_agnostic(),
         MultiSourceExpectation.phase_agnostic(
             instruction_environment=asrt.fail('unconditional failure')
         ),
     )
예제 #3
0
 def test_fail_due_to_unsatisfied_assertion_on_primitive(self):
     self._check_raises_test_error__single_and_multi(
         ConstantParser(_MATCHER_THAT_MATCHES),
         Expectation(
             execution=ExecutionExpectation(),
             primitive=prim_asrt__constant(asrt.fail('primitive'))
         ),
     )
 def test_fail_due_to_assertion_on_instruction_environment(self):
     with self.assertRaises(utils.TestError):
         self._check(
             PARSER_THAT_GIVES_SUCCESSFUL_INSTRUCTION,
             single_line_source(),
             ArrangementWithSds(),
             sut.Expectation(assertion_on_instruction_environment=asrt.fail('unconditional failure')),
         )
예제 #5
0
파일: prune.py 프로젝트: emilkarlen/exactly
def test_fails_if_applied(put: unittest.TestCase) -> FileMatcherSymbolContext:
    return FileMatcherSymbolContext.of_sdv(
        'test_fails_if_applied',
        sdv_components.matcher_sdv_from_constant_primitive(
            matcher_w_init_action.matcher_that_applies_assertion(
                put,
                asrt.fail('must not be applied'),
                lambda x: x,
                asrt.MessageBuilder.new_empty(),
                True,
            )))
예제 #6
0
    def test_SHOULD_not_match_WHEN_assertion_on_matcher_fails(self):
        # ARRANGE #
        cases = [
            NameAndValue('without symbol table', None),
            NameAndValue(
                'with symbol table',
                StringSymbolContext.of_sdv('the symbol name',
                                           CONSTANT_STRING_SDV).symbol_table,
            ),
        ]
        sdv_of_actual = ARBITRARY_SDV

        for case in cases:
            with self.subTest(name=case.name):
                assertion_to_check = sut.matches_regex_sdv(
                    primitive_value=lambda tcds: asrt.fail('unconditionally'),
                    symbols=case.value)
                # ACT & ASSERT #
                assert_that_assertion_fails(assertion_to_check, sdv_of_actual)
예제 #7
0
    def test_SHOULD_not_match_WHEN_assertion_on_matcher_fails(self):
        # ARRANGE #
        cases = [
            NameAndValue('without symbol table', None),
            NameAndValue(
                'with symbol table',
                StringMatcherSymbolContext(
                    'the symbol name', string_matcher.
                    ARBITRARY_SYMBOL_VALUE_CONTEXT).symbol_table,
            ),
        ]
        sdv_of_actual = ARBITRARY_STRING_MATCHER_SDV

        for case in cases:
            with self.subTest(name=case.name):
                assertion_to_check = _matches_string_matcher_sdv(
                    primitive_value=asrt.fail('unconditionally'),
                    symbols=case.value)
                # ACT & ASSERT #
                assert_that_assertion_fails(assertion_to_check, sdv_of_actual)
예제 #8
0
    def test_SHOULD_not_match_WHEN_assertion_on_matcher_fails(self):
        # ARRANGE #
        cases = [
            NameAndValue('without symbol table',
                         None),
            NameAndValue('with symbol table',
                         singleton_symbol_table_2(
                             'the symbol name',
                             symbol_utils.container(CONSTANT_STRING_RESOLVER),
                         )),

        ]
        resolver_of_actual = ARBITRARY_RESOLVER

        for case in cases:
            with self.subTest(name=case.name):
                assertion_to_check = sut.matches_regex_resolver(
                    primitive_value=lambda tcds: asrt.fail('unconditionally'),
                    symbols=case.value)
                # ACT & ASSERT #
                assert_that_assertion_fails(assertion_to_check, resolver_of_actual)
예제 #9
0
 def _assertion_for(value) -> ValueAssertion:
     try:
         return _IS_CROSS_REFERENCE_ID_ASSERTION_GETTER.visit(value)
     except TypeError:
         return asrt.fail('Not an instance of {}: {}'.format(CrossReferenceId, value))
예제 #10
0
def check_of_primitive_value_fails_expectedly(tcds: HomeAndSds) -> ValueAssertion[Pattern]:
    return asrt.fail('unconditional failure')
예제 #11
0
 def _assertion_for(value) -> Assertion:
     try:
         return _IS_CROSS_REFERENCE_ID_ASSERTION_GETTER.visit(value)
     except TypeError:
         return asrt.fail('Not an instance of {}: {}'.format(CrossReferenceId, value))
예제 #12
0
def check_of_primitive_value_fails_expectedly(
        tcds: TestCaseDs) -> Assertion[Pattern]:
    return asrt.fail('unconditional failure')