Skip to Content
Learn Python by Building Data Science Applications
book

Learn Python by Building Data Science Applications

by Philipp Kats, David Katz
August 2019
Beginner
482 pages
12h 56m
English
Packt Publishing
Content preview from Learn Python by Building Data Science Applications

Writing our own tests

But seriously, let's write a test of our own now. First, let's start with something relatively basic, such as finding out how our functions extract data from a given page and its elements. 

There is not much value in testing the ability of the requests library to collect pages from the web—it is safe to assume it does, and it has its own tests. Because of that, we moved all the parsing code from the parse_battle_page function into a private _parse_page function. This way, we can focus on testing the parsing, not the internet.

First, we'll store an HTML page of a few battles in the tests/data/pages folder. Now we will create a file called test_collect_battles.py—here we'll store all our tests for this particular module. ...

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

Python for Data Science

Python for Data Science

Yuli Vasiliev
Introduction to Machine Learning with Python

Introduction to Machine Learning with Python

Andreas C. Müller, Sarah Guido

Publisher Resources

ISBN: 9781789535365Supplemental Content