question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using one cassete per test class

See original GitHub issue

Hiya,

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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ktosiekcommented, Jun 19, 2017

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).

0reactions
paweladcommented, Jun 19, 2017

For now you should be able to get the behaviour you want by overriding the vcr_cassette_name fixture.

Yeah, you’re right, that’s basically what I did here with an additional config argument - thanks!

Also, that would use the same file twice - so it would only work if all those tests make the same set of requests.

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 : -)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found