Пример #1
0
 def test_count_multiple_occurences(self):
     self.assertEqual({
         'one': 1,
         'fish': 4,
         'two': 1,
         'red': 1,
         'blue': 1
     }, word_count('one fish two fish red fish blue fish'))
 def test_preserves_punctuation(self):
     self.assertEqual(
         {
             'car': 1,
             'carpet': 1,
             'as': 1,
             'java': 1,
             'javascript': 1
         }, word_count('car : carpet as java : javascript!!&@$%^&'))
 def test_non_alphanumeric(self):
     self.assertEqual(
         {
             'hey': 1,
             'my': 1,
             'spacebar': 1,
             'is': 1,
             'broken': 1
         }, word_count('hey,my_spacebar_is_broken.'))
 def test_tabs(self):
     self.assertEqual(
         {
             'rah': 2,
             'ah': 3,
             'roma': 2,
             'ma': 1,
             'ga': 2,
             'oh': 1,
             'la': 2,
             'want': 1,
             'your': 1,
             'bad': 1,
             'romance': 1
         },
         word_count('rah rah ah ah ah\troma roma ma\tga ga oh la la\t'
                    'want your bad romance'))
 def test_newlines(self):
     self.assertEqual(
         {
             'rah': 2,
             'ah': 3,
             'roma': 2,
             'ma': 1,
             'ga': 2,
             'oh': 1,
             'la': 2,
             'want': 1,
             'your': 1,
             'bad': 1,
             'romance': 1
         },
         word_count('rah rah ah ah ah\nroma roma ma\n'
                    'ga ga oh la la\nwant your bad romance'))
Пример #6
0
 def test_count_one_of_each(self):
     self.assertEqual({
         'one': 1,
         'of': 1,
         'each': 1
     }, word_count('one of each'))
Пример #7
0
 def test_count_one_word(self):
     self.assertEqual({'word': 1}, word_count('word'))
Пример #8
0
 def test_newlines(self):
     self.assertEqual(
         {'rah': 2, 'ah': 3, 'roma': 2, 'ma': 1, 'ga': 2, 'oh': 1, 'la': 2,
          'want': 1, 'your': 1, 'bad': 1, 'romance': 1},
         word_count('rah rah ah ah ah\nroma roma ma\nga ga oh la la\nwant your bad romance')
     )
Пример #9
0
 def test_multiple_spaces(self):
     self.assertEqual(
         {'wait': 1, 'for': 1, 'it': 1},
         word_count('wait for       it')
     )
Пример #10
0
 def test_mixed_case(self):
     self.assertEqual(
         {'go': 1, 'Go': 1, 'GO': 1},
         word_count('go Go GO')
     )
Пример #11
0
 def test_unicode(self):
     self.assertEqual(
         {
             decode_if_needed('аДаО'): 1,
             decode_if_needed('баВаИаДаАаНаИб'): 1
         }, word_count('аДаО№Ÿ––баВаИаДаАаНаИб!'))
Пример #12
0
 def test_mixed_case(self):
     self.assertEqual({'go': 1, 'Go': 1, 'GO': 1}, word_count('go Go GO'))
Пример #13
0
 def test_count_multiple_occurences(self):
     self.assertEqual(
         {'one': 1, 'fish': 4, 'two': 1, 'red': 1, 'blue': 1},
         word_count('one fish two fish red fish blue fish')
     )
Пример #14
0
 def test_count_one_of_each(self):
     self.assertEqual(
         {'one': 1, 'of': 1, 'each': 1},
         word_count('one of each')
     )
Пример #15
0
 def test_count_one_word(self):
     self.assertEqual(
         {'word': 1},
         word_count('word')
     )
Пример #16
0
 def test_mixed_case(self):
     self.assertEqual([2, 3],
                      sorted(list(
                          word_count('go Go GO Stop stop').values())))
Пример #17
0
 def test_include_numbers(self):
     self.assertEqual({
         'testing': 2,
         '1': 1,
         '2': 1
     }, word_count('testing 1 2 testing'))
Пример #18
0
 def test_preserves_punctuation(self):
     self.assertEqual(
         {'car': 1, 'carpet': 1, 'as': 1, 'java': 1, ':': 2, 'javascript!!&@$%^&': 1},
         word_count('car : carpet as java : javascript!!&@$%^&')
     )
Пример #19
0
 def test_multiple_spaces(self):
     self.assertEqual({
         'wait': 1,
         'for': 1,
         'it': 1
     }, word_count('wait for       it'))
Пример #20
0
 def test_include_numbers(self):
     self.assertEqual(
         {'testing': 2, '1': 1, '2': 1},
         word_count('testing 1 2 testing')
     )