Exemple #1
0
    def test_several_paragraphs(self):
        bot = BodyOfText('''This is a longer story.

Once upon a time, there was a princess in a castle.

She grew up to be a famous dancer.''')
        self.assertEqual(3, bot.num_paragraphs())
Exemple #2
0
    def test_several_paragraphs(self):
        bot = BodyOfText(
            '''1st paragraph.
2nd paragraph.
3rd paragraph.'''
        )
        self.assertEqual(3, bot.num_paragraphs())
        self.assertEqual(['1st paragraph.',
                          '2nd paragraph.',
                          '3rd paragraph.'], bot.paragraphs())
    def test_several_paragarphs(self):

        text = """This is a rather short story. It has three paragraphs.

        Once upon a time, a brave princess went on a dangerous journey. She
        had many adventures, and recruited other heros to her important and
        noble cause.

        She prevailed, saving the day, and made it home. Yay!"""
        bodyOfText = BodyOfText(text)
        self.assertEqual(3, bodyOfText.num_paragraphs())
 def test_wordcounts(self):
     testitems = [
         {'text' : 'This is a sentence.',
          'counts' : {'this': 1, 'is': 1, 'a': 1, 'sentence': 1},
         },
         {'text': 'Truth is beauty; beauty, truth.',
          'counts': {'truth': 2, 'beauty': 2, 'is': 1},
          },
         {'text': 'I could finally SEE. But what I could see, remained a mystery.',
          'counts': {'i': 2, 'could': 2, 'finally': 1, 'see': 2,
                     'but': 1, 'what': 1, 'remained': 1, 'a': 1, 'mystery': 1},
          },
         ]
     for testitem in testitems:
         with self.subTest(text=testitem['text'], counts=testitem['counts']):
             body = BodyOfText(testitem['text'])
             self.assertEqual(testitem['counts'], body.wordcounts())
Exemple #5
0
 def test_single_paragraph(self):
     bot = BodyOfText('Hello, world.')
     self.assertEqual(1, bot.num_paragraphs())
Exemple #6
0
 def test_empty_story(self):
     with self.assertRaises(ValueError):
         BodyOfText('')
Exemple #7
0
 def test_empty_story(self):
     bot = BodyOfText('')
     self.assertEqual(0, bot.num_paragraphs())
 def test_single_paragraph(self):
     bodyOfText = BodyOfText("Hello girls")
     self.assertEqual(1, bodyOfText.num_paragraphs())
Exemple #9
0
 def test_single_paragraph(self):
     bot = BodyOfText('This is a short story. It has only one paragraph.')
     self.assertEqual(1, bot.num_paragraphs())
     self.assertEqual(['This is a short story. It has only one paragraph.'], bot.paragraphs())
 def test_single_paragraph(self):
     single_paragraph_bot = BodyOfText("Hello, Alex")
     self.assertEqual(1, single_paragraph_bot.num_paragraphs())
     self.assertEqual(["Hello, Alex"], single_paragraph_bot.paragraphs())