mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-08 16:53:23 +00:00
* Drop support for legacy Python 2.7 * Upgrade Python syntax with pyupgrade --py3-plus * Trim testing matrix to remove python2 * re-enable python3.8 in travis as tests that are not allowed to fail * Remove some six * The future is now * Remove Python 2 imports * Add back example, but change py27 to py36 * Remove redundant compat.py * Blacken * Credit hugovk in changelog WIP Updating Sphinx Docs and AutoDoc * Fix AutoDoc and update Sphinx theme to python_doc_theme * Fix #420, autodoc even undocumented (docstring-less) method signatures * Doc theme 'nature'. Add global TOC to doc sidebar * Comment last reference to package six * Changelog is now a consistent format * Yet another documentation fix for links and title hierarchy * Start work on new SVG logo test SVG in README trying to test new SVG logo in README Apply centering Apply readme logo centering Trying to align image Trying random shit trying align right add emoji Large logo has higher priority Change title hierarchy Actually use a H1 Try again try and organise badges revert link back to point at master * updated new take on VCR logo as SVG code * Testing modern logo in docs * Add sanitize for rendering SVG * Switch to alabaster theme * Update vcrpy logo (#503) * Add credit for V4 logo changes. * Add rewind and play animation * Add svg into ReadTheDocs static assets so that it can be hosted so the animations work. * Need to embedd the SVG for ReadTheDocs somewhere so I can get the link to later embed in the README Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: Sean Bailey <sean@seanbailey.io>
58 lines
2.1 KiB
ReStructuredText
58 lines
2.1 KiB
ReStructuredText
Debugging
|
|
=========
|
|
|
|
VCR.py has a few log messages you can turn on to help you figure out if
|
|
HTTP requests are hitting a real server or not. You can turn them on
|
|
like this:
|
|
|
|
.. code:: python
|
|
|
|
import vcr
|
|
import requests
|
|
import logging
|
|
|
|
logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from vcrpy
|
|
vcr_log = logging.getLogger("vcr")
|
|
vcr_log.setLevel(logging.INFO)
|
|
|
|
with vcr.use_cassette('headers.yml'):
|
|
requests.get('http://httpbin.org/headers')
|
|
|
|
The first time you run this, you will see::
|
|
|
|
INFO:vcr.stubs:<Request (GET) http://httpbin.org/headers> not in cassette, sending to real server
|
|
|
|
The second time, you will see::
|
|
|
|
INFO:vcr.stubs:Playing response for <Request (GET) http://httpbin.org/headers> from cassette
|
|
|
|
If you set the loglevel to DEBUG, you will also get information about
|
|
which matchers didn't match. This can help you with debugging custom
|
|
matchers.
|
|
|
|
CannotOverwriteExistingCassetteException
|
|
----------------------------------------
|
|
|
|
When a request failed to be found in an existing cassette,
|
|
VCR.py tries to get the request(s) that may be similar to the one being searched.
|
|
The goal is to see which matcher(s) failed and understand what part of the failed request may have changed.
|
|
It can return multiple similar requests with :
|
|
|
|
- the matchers that have succeeded
|
|
- the matchers that have failed
|
|
- for each failed matchers, why it has failed with an assertion message
|
|
|
|
CannotOverwriteExistingCassetteException message example :
|
|
|
|
.. code::
|
|
|
|
CannotOverwriteExistingCassetteException: Can't overwrite existing cassette ('cassette.yaml') in your current record mode ('once').
|
|
No match for the request (<Request (GET) https://www.googleapis.com/?alt=json&maxResults=200>) was found.
|
|
Found 1 similar requests with 1 different matchers :
|
|
|
|
1 - (<Request (GET) https://www.googleapis.com/?alt=json&maxResults=500>).
|
|
Matchers succeeded : ['method', 'scheme', 'host', 'port', 'path']
|
|
Matchers failed :
|
|
query - assertion failure :
|
|
[('alt', 'json'), ('maxResults', '200')] != [('alt', 'json'), ('maxResults', '500')]
|