Replay network requests on your tests: VCR.py
Today I’m happy to present you another library to aid with testing, this time related to tests that need network conectivity: VCR.py
VCR.py, a Python version of Ruby’s VCR, works by recording the HTTP requests and responses your test makes, and then replays them when the tests is run again, thus achieving network independence. As a side effect, it also makes the test much faster, which is always nice.
Using it on a typical test is very easy, you just need to import it, and then surround the test that will interact with the network with a with vcr.cassete() block: