Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed bugs

  • Loading branch information...
commit 70063ff387513e054f7327624ed52a05b2f4af91 1 parent c06fb69
jen authored
Showing with 17 additions and 10 deletions.
  1. +3 −3 auto_tagify.py
  2. +14 −7 auto_tagifytests.py
View
6 auto_tagify.py
@@ -1,7 +1,7 @@
import re
-class auto_tagify():
- stop_word = re.compile('(^(th|wh|hi|sh|an|ha|wa)[adeisouy]$)|(^(th|wh|do|is|he)[aeionur][nste]$)|(^(wh|th|h|w)(ere))|(^(w|sh|c)(ould))|(but)|(how)|(very)|(really)')
+class AutoTagify():
+ stop_word = re.compile('(^(th|wh|hi|sh|an|ha|wa)[adeisouy]$)|(^(th|wh|do|is|he)[aeionur][nste]$)|(^(wh|th|h|w)(ere))|(^(w|sh|c)(ould))|(but)|(how)|(very)|(really)|(with)')
eol = re.compile('[\r\n\t]')
clean_word = re.compile('[\[\],().;:"\'?!*&<>/\+={}`~]')
clean_link = re.compile('(?<=^\/)\/+|\/+$')
@@ -29,7 +29,7 @@ def tag_list(self):
for word in self.eol.sub(' ',self.text).split(' '):
tag_word = self.clean_word.sub('',word).lower()
- if len(tag_word) >= self.min_word_length and not self.stop_word.match(word):
+ if len(tag_word) >= self.min_word_length and not self.stop_word.match(tag_word):
tag_words.append(tag_word)
return tag_words
View
21 auto_tagifytests.py
@@ -1,5 +1,5 @@
import unittest
-from auto_tagify import auto_tagify
+from auto_tagify import AutoTagify
class AutoTagifyTestCase(unittest.TestCase):
@@ -7,24 +7,31 @@ def testTextNotEmpty(self):
"""
Verify text returns content, if text is provided and not null
"""
- a = auto_tagify()
+ a = AutoTagify()
a.text = 'This is a test'
- assert a.generate()
+ a.css = "taggable"
+ self.assertEqual(a.generate(), 'This is a <a href="/test" class="taggable">test</a> ')
def testTextEmpty(self):
"""
Verify sending no text returns nothing
"""
- a = auto_tagify()
- assert a.generate()
+ a = AutoTagify()
+ self.assertEqual(a.generate(), ' ')
def testTagsNotEmpty(self):
"""
Verify that tags are returned
"""
- a = auto_tagify()
+ a = AutoTagify()
a.text = 'This is a test with other valid taggable items'
- assert a.tag_list
+ test_array = []
+ test_array.append('test')
+ test_array.append('other')
+ test_array.append('valid')
+ test_array.append('taggable')
+ test_array.append('items')
+ self.assertEqual(a.tag_list(), test_array)
if __name__ == "__main__":
unittest.main()
Please sign in to comment.
Something went wrong with that request. Please try again.