pytest-vcr | Py.test integration with VCR.py | Plugin library
kandi X-RAY | pytest-vcr Summary
kandi X-RAY | pytest-vcr Summary
Py.test integration with VCR.py
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Read the contents of a file .
pytest-vcr Key Features
pytest-vcr Examples and Code Snippets
Community Discussions
Trending Discussions on pytest-vcr
QUESTION
I have started using pytest-vcr
which is a pytest
plugin wrapping VCR.py
which I have documented in this blog post on Advanced Python Testing.
It records all HTTP traffic to cassettes/*.yml
files on the first test run to save snapshots. Similar to Jest snapshot testing for web components.
On subsequent test runs, if a request is malformed, it won't find a match and throws an exception saying that recording new requests is forbidden and it did not find an existing recording.
QuestionVCR.py
raises a CannotOverwriteExistingCassetteException
which is not particularly informative as to why it didn't match.
How do I leverage pytest
pytest_exception_interact
hooks to replace this exception with a more informative one leveraging fixture information?
I dove into my site-packages
where VCR.py
is pip installed
and rewrote how I want it to handle the exception. I just need to know how to get this pytest_exception_interact
hook to work correctly to access the fixtures from that test node (before it gets cleaned up) and raise a different exception.
Lets get the dependencies.
...ANSWER
Answered 2019-Aug-10 at 21:07Thanks to comments and guidance in the comments from @hoefling.
I could attach the cassette
fixture to the request.node
in a conftest.py
local plugin overriding the pytest-vcr
marker...
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pytest-vcr
You can use pytest-vcr like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page