
朴素贝叶斯分类
|
53
self.assertEqual(self.plain_email.body(), body)
def test_parses_the_subject(self):
subject = re.search("Subject: (.*)", self.text).group(1)
self.assertEqual(self.plain_email.subject(), subject)
Unit Testing in Python
Up until this point we haven’t introduced the unittest package in Python. Its main
objective is to define unit tests for us to run on our code. Like similar unit testing
frameworks in other languages like Ruby, we build a class that is prefixed with “Test”
and then implement specific methods.
Methods to implement:
• Any method that is prefixed with
test_ will be treated as a test to be run.
•
setUp(self) is a special method ...