August 2019
Beginner
482 pages
12h 56m
English
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. ...