Commits

Takayuki KONDO committed c38a4ee

detectメソッド実装

  • Participants

Comments (0)

Files changed (4)

+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>WordFilter</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.python.pydev.PyDevBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.python.pydev.pythonNature</nature>
+	</natures>
+</projectDescription>

File .pydevproject

+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
+<path>/WordFilter</path>
+</pydev_pathproperty>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+</pydev_project>

File test_wordfilter.py

+#!/usr/bin/env python
+# coding: utf-8
+
+from wordfilter import WordFilter
+import unittest
+
+
+class WordFilterTest(unittest.TestCase):
+    def test_detect(self):
+        self.assertTrue(WordFilter("Arsenal").detect(u"t_wada:昨日のArsenal vs Chelsea 熱かった!"))
+        self.assertFalse(WordFilter("Arsenal").detect(u"t_wada:昨日の Chelsea 熱かった!"))
+
+
+if __name__ == "__main__":
+    unittest.main()

File wordfilter.py

+#!/usr/bin/env python
+
+class WordFilter:
+    word = ""
+    def __init__(self, word):
+        self.word = word
+        
+    def detect(self, msg):
+        if msg.find(self.word) == -1:
+            return False
+        return True
+    
+    
+