Skip to Main Content
Python 机器学习实践:测试驱动的开发方法
book

Python 机器学习实践:测试驱动的开发方法

by Matthew Kirk
January 2018
Intermediate to advanced content levelIntermediate to advanced
211 pages
8h 31m
Chinese
China Machine Press
Content preview from Python 机器学习实践:测试驱动的开发方法
朴素贝叶斯分类
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Python for Bioinformatics

Mastering Python for Bioinformatics

Ken Youens-Clark

Publisher Resources

ISBN: 9787111581666