Esempio n. 1
0
    def test(self):
        # ARRANGE #
        const_pi = Paragraph([])
        cases = [
            NEA('empty sequence of paragraphs',
                expected=asrt.matches_sequence([]),
                actual=[]
                ),
            NEA('single paragraph',
                expected=asrt.matches_sequence([
                    asrt.is__any(const_pi)
                ]),
                actual=[const_pi]
                ),
        ]

        for case in cases:
            with self.subTest(case.name):
                # ACT #

                actual = sut.constant(case.actual).apply(CONSTRUCTION_ENVIRONMENT)

                # ASSERT #

                case.expected.apply_without_message(self, actual)
Esempio n. 2
0
    def test(self):
        # ARRANGE #
        const_pi_1 = Paragraph([])
        const_pi_2 = Paragraph([StringText('const pi 2')])
        const_pi_3 = Paragraph([StringText('const pi 3')])
        cases = [
            NEA('empty sequence of paragraphs',
                expected=asrt.matches_sequence([]),
                actual=[]
                ),
            NEA('single constructor',
                expected=asrt.matches_sequence([
                    asrt.is__any(const_pi_1)
                ]),
                actual=[sut.constant([const_pi_1])]
                ),
            NEA('multiple constructors',
                expected=asrt.matches_sequence([
                    asrt.is__any(const_pi_1),
                    asrt.is__any(const_pi_2),
                    asrt.is__any(const_pi_3),
                ]),
                actual=[sut.constant([const_pi_1,
                                      const_pi_2]),
                        sut.constant([const_pi_3])]
                ),
        ]

        for case in cases:
            with self.subTest(case.name):
                # ACT #

                actual = sut.sequence(case.actual).apply(CONSTRUCTION_ENVIRONMENT)

                # ASSERT #

                case.expected.apply_without_message(self, actual)
Esempio n. 3
0
 def test_true(self):
     expected_object = 'expected object'
     sut.is__any(expected_object).apply(self.put, expected_object)
     sut.is__any(expected_object).apply(self.put, expected_object,
                                        sut.MessageBuilder('head'))
Esempio n. 4
0
 def test_false__with_message_builder(self):
     expected_object = 'expected object'
     actual_object = 'actual object'
     with self.assertRaises(TestException):
         sut.is__any(expected_object).apply(self.put, actual_object,
                                            sut.MessageBuilder('head'))
Esempio n. 5
0
 def test_true(self):
     expected_object = 'expected object'
     sut.is__any(expected_object).apply(self.put, expected_object)
     sut.is__any(expected_object).apply(self.put, expected_object,
                                        sut.MessageBuilder('head'))
Esempio n. 6
0
 def test_false__with_message_builder(self):
     expected_object = 'expected object'
     actual_object = 'actual object'
     with self.assertRaises(TestException):
         sut.is__any(expected_object).apply(self.put, actual_object,
                                            sut.MessageBuilder('head'))