def test_sanity():
    """Feed output of a class into itself"""
    text_a = TextBody(open('moby_dick.txt').read())
    words_before = text_a.words[:]
    copy = ' '.join(text_a.words)
    text_b = TextBody(copy)
    assert_(words_before, text_b.words)
Ejemplo n.º 2
0
 def test_word_number_two(self):
     """Count words in a short sentence"""
     text = TextBody("Call me Ishmael")
     self.assertEqual(text.word_number, 3)
def test_average_word_length():
    """Calculate average word length in a short sentence"""
    text = TextBody("Call me Ishmael")
    assert_almost_equal(text.average_word_length, 4.333, 3)
 def test_words(self):
     """The word attribute is a list"""
     words = ['my', 'name', 'is', 'ishmael']
     text = TextBody('Call me Ishmael')
     self.assertListEqual(text.words, words)
def test_nasty():
    """Ugly data example works."""
    text = TextBody("""That #~&%* program still doesn't work!
I already de-bugged it 3 times, and still numpy.array keeps throwing AttributeErrors.
What should I do?""")
    assert_(text.word_number, 22)
def test_typical():
    """Representative small input works."""
    text = TextBody("whale eats captain")
    assert_(text.words, ['whale', 'eats', 'captain'])
def test_biggest():
    """An entire book works."""
    text = TextBody(open('moby_dick.txt').read())
    assert_(text.word_number, 200000)
def test_smallest():
    """Minimal string works."""
    text = TextBody("whale")
    assert_(text.words, ['whale'])
def test_empty():
    """Empty input works"""
    text = TextBody('')
    assert_(text.word_number, 0)
def test_words():
    """The word attribute is a list"""
    words = ['my', 'name', 'is', 'ishmael']
    text = TextBody('Call me Ishmael')
    assert_list_equal(text.words, words)
 def test_smallest(self):
     """Minimal string works."""
     text = TextBody("whale")
     self.assert_x(text.words, ['whale'])
 def test_empty(self):
     """Empty input works"""
     text = TextBody('')
     self.assert_x(text.word_number, 0)