Open mlissner opened 7 years ago
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.
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!
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).
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.
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 👏
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 =)
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.
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.
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?