Giter VIP home page Giter VIP logo

Comments (8)

fatuhoku avatar fatuhoku commented on June 1, 2024

And when running with wifi connected, I'm almost certain that both times the request was still made to the servers!

from vcrpy.

fatuhoku avatar fatuhoku commented on June 1, 2024

The integration test here fails when run without a wifi connection.

from vcrpy.

fatuhoku avatar fatuhoku commented on June 1, 2024

Note also that the integration test for testing POST requests is for some reason using redirect.yaml. I suspect this is a copy-and-paste error!

# In https://github.com/kevin1024/vcrpy/blob/master/tests/integration/test_requests.py...
def test_post(tmpdir, scheme):
    '''Ensure that we can post and cache the results'''
    data = {'key1': 'value1', 'key2': 'value2'}
    url = scheme + '://httpbin.org/post'
    with vcr.use_cassette(str(tmpdir.join('redirect.yaml'))) as cass:
    ...

from vcrpy.

kevin1024 avatar kevin1024 commented on June 1, 2024

I run this test the first time with my wifi connected and a second time with my wifi disconnected.

I'm unable to reproduce this problem. I ran your sample code once with the wifi on, and it produced the yaml file, and the second time with wifi off, and the test still passed.

Was fixtures/foobar.yaml created when you ran the test the first time?

Note also that the integration test for testing POST requests is for some reason using redirect.yaml.

Yeah, it's a copy/paste error, though it doesn't actually matter since those files are in a tmpdir specifically created just for that one test run. I'll fix that though, thanks for the heads-up.

The integration test here fails when run without a wifi connection.

Yes, the VCR test suite requires an internet connection (except for the unit tests, which don't make network requests). I decided to do this so I can test the creation of cassettes and to ensure that the connection correctly passes through to httplib if there is no cassette (too bad I can't use VCR to test VCR!)

from vcrpy.

fatuhoku avatar fatuhoku commented on June 1, 2024

Hey @kevin1024, thanks for responding promptly.

Apologies! The code I posted really doesn't produce the problem. I found a more clear way to reproduce the problem and updated the issue description:

        # This test SUCCEEDS
        def test_vcr_works_with_requests():
            with vcr.use_cassette('fixtures/test_vcr/foobar.yaml'):
                r = requests.post("http://requestb.in/179gbs61")

        # This test FAILS
        def test_vcr_works_with_requests_with_file_upload():
            with vcr.use_cassette('fixtures/test_vcr/foobar-file-upload.yaml'):
                with open (os.path.abspath('lolcat.jpg')) as f:
                    r = requests.post("http://requestb.in/179gbs61", files={'photo':f})

Yes, the VCR test suite requires an internet connection

Well I hope VCR tests in general do not require it — although we're always connected nowadays it's a matter of principle that tests should pass without it!

from vcrpy.

fatuhoku avatar fatuhoku commented on June 1, 2024

So I'm doing some detective work around this because I really want to get this working.

The relevant part that discriminates the two requests.post calls is:
https://github.com/kennethreitz/requests/blob/master/requests/models.py#L404

I'm no expert, but @kevin1024 you may be able to spot why VCR might be tripping up here.

from vcrpy.

fatuhoku avatar fatuhoku commented on June 1, 2024

Okay, with some Python debugging I found that this really is a simple case of the vcr.Request not being looked up in the requests OrderedDict correctly. Though the cassette strictly speaking contains the request, when performing the lookup the hashes mustn't have matched for some reason. I'll look into this further.

from vcrpy.

kevin1024 avatar kevin1024 commented on June 1, 2024

Closing since #29 and #30 address this same issue.

from vcrpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.