Using one cassete per test class
See original GitHub issueHiya,
Thanks for the plugin, I like it a lot. One thing that I’m wondering if it’s possible / worth doing is allowing marked classes to use one cassete, so:
@pytest.mark.vcr()
def test_foo():
pass
@pytest.mark.vcr()
def test_bar():
pass
would create test_foo.yaml
and test_bar.yaml
as you’d expect, but:
@pytest.mark.vcr()
class TestFoobar:
def test_foo(self):
pass
def test_bar(self):
pass
would only create one cassete TestFoobar.yaml
instead of TestFoobar.test_foo.yaml
and TestFoobar.test_bar.yaml
.
I don’t know if that’s even possible re py.test and vcr.py but wanted to ask, as it would make sense in my use case when I’m class is a group of tests of one function (which does one external request) but with different parameter.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
best practices, test::unit, cassette per test? erasing cassettes?
Hi, I'm a newcomer to VCR. My code makes lots of HTTP requests to a variety of third party services, so VCR is...
Read more >How to Use The VCR Gem to Improve Your Testing Suite
Notice that this will create one cassette per test… Even if two tests make the same request & use the same data. VCR...
Read more >Mock testing in python using vcrpy | by Tarannum Khan
You just need to run the test online once when the cassette file which stores all the important information related to the requests...
Read more >Add option to specify cassette path · Issue #1 · php-vcr/phpunit ...
I wrote a change that allows you to specify the cassette path. ... per test, it would remove the convenience of setting it...
Read more >Custom VCR request matching options for some specific ...
I have a bunch of RSpec tests in my Rails project that test HTTP calls to external REST API and use VCR cassettes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t see this being common, but I’ll leave the issue open for now, so if anyone else has a similar use-case they can leave a comment.
For integrating this in the plugin I’d also have to look at how VCR.py behaves when multiple tests are trying to create the same file (with xdist).
Yeah, you’re right, that’s basically what I did here with an additional config argument - thanks!
That’s my exact use case but I wonder how often that is and if that’s actually a good practice and worth implementing into the plugin - the answer very well could be no : -)