예제 #1
0
 def test_true(self):
     value = [None]
     sut.sub_component('component name', lambda x: x[0],
                       sut.ValueIsNone()).apply(self.put, value)
     sut.sub_component('component name', lambda x: x[0],
                       sut.ValueIsNone()).apply(
                           self.put, value,
                           sut.MessageBuilder('message head'))
예제 #2
0
 def test_false__with_message_builder(self):
     with self.assertRaises(TestException):
         value = ['not none']
         sut.sub_component('component name', lambda x: x[0],
                           sut.ValueIsNone()).apply(
                               self.put, value,
                               sut.MessageBuilder('message head'))
예제 #3
0
def matches_symbol_reference_with_restriction_on_direct_target(
        expected_name: str,
        assertion_on_direct_restriction: Assertion[ValueRestriction]
) -> Assertion[SymbolReference]:
    return asrt_sym_ref.matches_reference_2(expected_name,
                                            asrt_w_str_rend_rest.matches__on_direct_and_indirect(
                                                assertion_on_direct=assertion_on_direct_restriction,
                                                assertion_on_indirect=asrt.ValueIsNone()))
예제 #4
0
                                   asrt.equals(part.selector)),
                asrt.sub_component(
                    'restriction', OrRestrictionPart.restriction.fget,
                    _equals_on_direct_and_indirect(part.restriction)),
            ])) for part in expected.parts
    ]
    return asrt.is_instance_with(
        OrReferenceRestrictions,
        asrt.sub_component('parts', OrReferenceRestrictions.parts.fget,
                           asrt.matches_sequence(expected_sub_restrictions)))


REFERENCES_ARE_UNRESTRICTED = matches__on_direct_and_indirect(
    assertion_on_direct=asrt.is_instance(
        ArbitraryValueWStrRenderingRestriction),
    assertion_on_indirect=asrt.ValueIsNone())


def _equals_on_direct_and_indirect(
    expected: ReferenceRestrictionsOnDirectAndIndirect
) -> Assertion[ReferenceRestrictions]:
    return matches__on_direct_and_indirect(
        assertion_on_direct=asrt_val_rest.equals(expected.direct),
        assertion_on_indirect=(asrt.is_none if expected.indirect is None else
                               asrt_val_rest.equals(expected.indirect)))


class _EqualsDataTypeReferenceRestrictionsVisitor(
        TypeWithStrRenderingReferenceRestrictionsVisitor):
    def visit_direct_and_indirect(
            self, x: ReferenceRestrictionsOnDirectAndIndirect) -> Assertion:
예제 #5
0
 def test_not_none(self):
     with self.assertRaises(TestException):
         sut.ValueIsNone().apply(self.put, 'not none')
     with self.assertRaises(TestException):
         sut.ValueIsNone().apply(self.put, 'not none',
                                 sut.MessageBuilder('head'))
예제 #6
0
 def test_none(self):
     sut.ValueIsNone().apply(self.put, None)
     sut.ValueIsNone().apply(self.put, None, sut.MessageBuilder('head'))
예제 #7
0
 def setUp(self):
     self.put = test_case_with_failure_exception_set_to_test_exception()
     self.every_element_is_none = sut.every_element('iterable name',
                                                    sut.ValueIsNone())
예제 #8
0
 def test_true(self):
     value = [None]
     sut.OnTransformed(lambda x: x[0],
                       sut.ValueIsNone()).apply(self.put, value)
     sut.OnTransformed(lambda x: x[0], sut.ValueIsNone()).apply(
         self.put, value, sut.MessageBuilder('message head'))
예제 #9
0
 def test_false__with_message_builder(self):
     with self.assertRaises(TestException):
         value = ['not none']
         sut.OnTransformed(lambda x: x[0], sut.ValueIsNone()).apply(
             self.put, value, sut.MessageBuilder('message head'))
예제 #10
0
def is_success() -> Assertion[Optional[TextRenderer]]:
    return asrt.ValueIsNone()