Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why should we use this instead of VCR? #125

Open
mlissner opened this issue Nov 26, 2016 · 9 comments
Open

Why should we use this instead of VCR? #125

mlissner opened this issue Nov 26, 2016 · 9 comments

Comments

@mlissner
Copy link

mlissner commented Nov 26, 2016

I'm evaluating VCR and was ready to use it when I discovered this library. I read the readme, and some of the documentation, but I haven't found any explanation of why I would choose this over VCR.

The closest thing I've found is that this is VCR for python requests. But...VCR supports requests...so...where does that leave me?

Can this be clarified and added to the documentation?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/39549676-why-should-we-use-this-instead-of-vcr?utm_campaign=plugin&utm_content=tracker%2F198445&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F198445&utm_medium=issues&utm_source=github).
@sigmavirus24
Copy link
Collaborator

The closest thing I've found is that this is VCR for python requests.

It's a bit different than that. This was specifically written for python-requests. Because of that, we avoid some of the sharper edge cases users tend to have with VCR.py. There's a pretty significant number of companies choosing betamax over VCR.py due to the stability and maintenance of it.

Otherwise, it comes down to how you want to write your tests and what test framework integrations you want out of the box.

@kevin1024
Copy link

Author of VCR.py here. I would say the main difference between the two libraries is how they hook into the HTTP request cycle. VCR.py mocks at the httplib layer, while betamax uses an API on requests. The method betamax uses is cleaner, but limits the support to only requests. VCR.py can work with different http libraries (requests, urllib, urllib2, aiohttp, tornado, etc).

That said, I consider VCR to be well maintained and stable.

I would love to hear about any "sharp edge cases users tend to have with VCR.py" so I can fix them!

@mlissner
Copy link
Author

Just to be clear: I filed this bug because I wanted the documentation to clarify why Betamax exists. So far it sounds like it's a cleaner implementation (since it doesn't support other libraries), but as a user I don't much care about that, provided they work the same at the API level I use.

Are there concrete things we could add to the Betamax documentation that would help people like me that are trying to decide which library to use? Right now I haven't heard much (aside from cleanliness).

@sigmavirus24
Copy link
Collaborator

That said, I consider VCR to be well maintained and stable.

So when I wrote Betamax, VCR wasn't yet 1.0 and seemed quite dead. That's why Betamax exists today. I've no other reasoning beyond that anecdata about why people continue to pick Betamax over VCR.py

I would love to hear about any "sharp edge cases users tend to have with VCR.py" so I can fix them!

When I started Betamax I found a bunch. I found it easier to just write Betamax at the time since PRs were languishing and issues were staying open for quite a bit. Also, since I only cared about Requests, it was easier to do things in a Requests kind of way that completely avoids monkey-patching. At least one thing I remember running into was monkey-patches not being unset properly when a test errorred.


Honestly, I don't really have any compelling reasons for anyone to use Betamax over VCR.py. They both do the same thing but in different ways.

@dotsbb
Copy link

dotsbb commented Dec 23, 2016

I have found both libs in the same time. I like the source code of betamax - it's clean and easy to maintain.
But for my use case answer was clear after reading betamax's documentation.
There is a difference between these packages: vcspy plays better with functional tests which use 3 party libs (i.e oauth2 or external SDKs).

VCS:

@vcr_instance.use_cassette()
def test_my_endpoint_wich_uses_external_SDK(api_client):
    response = api_client.post(url)
    assert rv.status_code == 200

In tests with betamax you have to provide session instance as dependency injection to external SDKs by manually monkey-patching them.

@guyzmo
Copy link

guyzmo commented Dec 28, 2016

In tests with betamax you have to provide session instance as dependency injection to external SDKs by manually monkey-patching them.

or you can patch those external SDKs to actually support injection of the session. I have done that a few times.

That's one of the good sides of using FLOSS ☺

@sigmavirus24
Copy link
Collaborator

@guyzmo 👏

I, for one, wouldn't use an API client that didn't allow me to customize the underlying session anyway. There are times I know I'll need to configure Retries and I'll want to do those my way in Requests rather than rely on the library to do that for me. Then again I'm biased as a core developer of Requests =)

@mlissner
Copy link
Author

I appreciate the discussion here. Should we just put a link to this issue in the readme for betamax? It seems like this is as good as any documentation we could write.

Or we can just hope people find their way here and let lying dogs lay.

@sigmavirus24
Copy link
Collaborator

Woops! I didn't mean to close this. I've been thinking that an FAQ would be good to add to Betamax's published documentation. I'd like this added there if anyone wants to tackle starting that document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants