Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
Thomas Grainger
liamhession: how did it blow up to that size?
Requests with large responses. This is for a scraper of restaurant menu information
Thomas Grainger
liamhession: don't test at that level then
liamhession: pyvcr is a cruise missile for http tests
liamhession: you should create a function that parses the bit you want out of some web content
then test assert parses_the_bit_you_want_out_of_some_web_content(some_web_content) == the_bit_you_want
liamhession: it's always best to separate all of your IO code from the rest of your code
Thanks for the responses, @graingert. I'll have to tweak how i'm using vcr definitely
Meet Mangukiya
even though a request is recorded, it says it isn't recorded and raises cannot overwrite error
vcr.errors.CannotOverwriteExistingCassetteException: No match for the request (<Request (GET) http://webservices.coala.io/list/bears>) was found. Can't overwrite existing cassette ('tests/cassettes/coatils_list_bears.yaml') in your current record mode ('once').
one can see it is the first interaction
what is the problem here :/
Tomasz Kontusz
Hi! I'm the maintainer of a pytest plugin for VCR.py: https://github.com/ktosiek/pytest-vcr/ - I wanted to ask if it's common to operate on an active cassette directly?
is there anything interesting that can be done with an open cassette object except for closing it?
Tomasz Kontusz
I have to go to sleep now, but if anyone has an opinion on that (or uses self.cassette with vcrpy-unittest for anything) please either ping me or comment on ktosiek/pytest-vcr#5
Reece Hart
Anyone have an example of using vcrpy with doctests and pytest?
Tomasz Kontusz
@reece you can use https://pypi.python.org/pypi/pytest-vcr and getfixture('vcr_cassette')
see also https://docs.pytest.org/en/latest/doctest.html for more info on using doctests with pytest
(disclaimer: I've made that plugin)
Reece Hart
Thanks @ktosiek. Following up 1-1 with another question.
Ivan Malison
@ktosiek yes
but only if you want to do really shady stuff. It's actually available mostly for testing
I'm pretty sure that I added that a while back
Gavin Schneider
Hi there - I just started using vcrpy and pytest-vcr on an inherited project that is py2/3 compatible using the future package, and I am wondering if there is a trick to getting this to work correctly on py2 in this case. The short story is that I am getting urlopen error [Errno 61] Connection refused exceptions in py2 while py3 correctly replays the cassette (I did generate the cassette in py3 if that matters). The project is using urllib, and future was added to support py2/3 compatibility. It seems like in py2 vcr isn't wrapping/patching correctly. Anyone have experience with that or suggestions on how to deal with that? I am basically using defaults for everything here. Here is an extraction of the code (not from the test itself) that throws the exception (trimmed for brevity and relevance):
from __future__ import (absolute_import, division, print_function, unicode_literals)
from builtins import object
from future import standard_library
import urllib.request

request = urllib.request.Request(uri, post_data, headers)
response = urllib.request.urlopen(request)
Gavin Schneider
If it helps, you can see the travis-ci results here https://travis-ci.org/rapid7/nexpose-client-python/builds/292372011 but you'll probably need to look into the project code to see more useful details, and it's ... not very pretty :neutral_face:
Gavin Schneider

guess its due to the way python-future imports the urllib stuff. I am able to make it work by importing like this (yuck...):

if sys.version_info > (3, 3):
    from urllib.parse import urlparse, urlencode
    from urllib.request import urlopen, Request
    from urllib.error import HTTPError
    from urlparse import urlparse
    from urllib import urlencode
    from urllib2 import urlopen, Request, HTTPError

the try...except way of doing it didn't work, but maybe I need to play around with the future stuff some more

I can probably just switch to the requests lib instead :smile:
Hi all,
I just started using vcr play & I am able to record responses when I use urllib api's but same is not working for requests api. Can anyone please help me out here, is vcr not supported for requests api

from urllib.request import urlopen
from requests import request

with vcr.use_cassette('fixtures/vcr_cassettes/deva.yaml') as cass:
r = request('get', 'http://jsonplaceholder.typicode.com/')

with vcr.use_cassette('fixtures/vcr_cassettes/synopsis.yaml') as cass:
response = urlopen('http://www.zombo.com/').read()
assert len(cass) == 1

hey everyone,
great library saves me a lot of troubles while testing :smile:
my question is when do you plan next release? I'm interested on #326 .
if there is anything i can do to help please LMK, thanks!
Varun Kruthiventi
Hello all,
I was trying to mock S3 Boto requests. While using vcr, I see that the boto requests are not getting captured by vcr. Any idea ?
vcr version is 2.0.1
Jan Gazda
@saivarunk I have PR in progress, however tests are failing on issues not related to my implementation so you can use my branch #411
@kevin1024 does the library actually make use of this yaml tag? 'tag:yaml.org,2002:python/unicode' or is it just in migration testcase?
Josh Peak
@schmuelamar there are plans to get a Python3.8 compatible release out. kevin1024/vcrpy#447 There are some newer maintainers that have come on and are working with the original maintainers to work through the backlog of issues and PRs. The trickiest seems to be #382 the boto3 integration. Thanks Jan for pushing that one along!
Jan Gazda
@neozenith I started it as an experiment and I managed to get it working until I hit the last problem with urllib==1.25. Unfortunately I will not be able to commit to this in near future but I can still provide some AWS endpoints so the integration can be tested against it.
Mattia Procopio
hi all, is there any documentation on how to provide new stubs? I am interested in adding stub for httpx but I am quite lost at the moment reading through the code
Jan Gazda
afaik there aren't any docs , I agree it's bit messy (I went through the same process) but I guess if you open issue and PR, team should be able to give you some guidance
Alan Justino da Silva
Good morning.
Had anyone tried to mock IPFS calls? I am having problems with this as vcrpy seems to be ignoring the requests.get call results.
Initially I thought that it [IPFS] could be using some esoteric network driver, but no. It uses requests. Now I am thinking that it may be keeping the connection open. However, the context manager should handle even such cases, right?
Alan Justino da Silva
Progress: Looks like IPFS really does nasty things with monkeypatching, but I could get thru it
At the end, the issue is that vcr does not store "socket.timeout" exception as an answer to be replayed
I think this is a bug. Please let me know if I should raise an issue
Martynas Mickevičius
Hi all. Has there been an attempt for httpx support in vcrpy?
Gabriele Bonetti

Hi all. Has there been an attempt for httpx support in vcrpy?

also interested

Martynas Mickevičius
There is an open PR: kevin1024/vcrpy#523
Hi. Is there a way to use multiple cassettes at once? Because it didn't work when I tried it and I haven't found anything about it in the docs.
Ivan Malison
@gerwis1998 no
Hi there, i couldn't find a direct answer in the docs so maybe someone here can help. What is the support for async? I have a test that, when decorated with the cassette decorator, fails every time. The only difference between that test and all my others is the presence of async code. Thanks! (The issue seems to be that it's expecting different requests/ordering after the first cassette is made)