Beispiel #1
0
 def test_limit_with_40_chars_empty_source(self):
     # test parameter
     maxchars = 40
     # running service
     service = TextFormatter(text='')
     result = service.limiter(line_size_chars=maxchars)
     self.assertEqual('', result)
Beispiel #2
0
    def test_limit_with_40_chars_sample4(self):
        # test parameter
        maxchars = 40
        # get fixtures
        sample = 'sample4.txt'
        file = open(self.fixtures_base + sample, 'r')
        text = file.read()
        # running service
        service = TextFormatter(text=text)
        result = service.limiter(line_size_chars=maxchars)

        # assert result size
        total_of_source_words = self.count_words(text=text)
        total_of_result_words = self.count_words(text=result)
        self.assertEqual(total_of_source_words, total_of_result_words)
        # assert size of each line
        splited = result.split(TextFormatter.BREAK_LINE)
        for line in splited:
            self.assertTrue(len(line) <= maxchars)