Giter Site home page Giter Site logo

Comments (3)

kevin1024 avatar kevin1024 commented on May 17, 2024

Currently no. The reason is that VCR only patches the HTTP code while inside the context manager, so I can't modify HTTP requests outside of that context.

If there is sufficient interest I can look into this, but I think it would involve monkey patching at import time so I'm not too excited about the implementation.

from vcrpy.

msabramo avatar msabramo commented on May 17, 2024

As a bystander unfamiliar with the Ruby version, I thought that maybe this feature was to raise an error if using the context manager and the cassette file wasn't present. But I was probably wrong as I've never used the Ruby version. That seems like a useful feature -- is that possible already?

As for disallowing requests when not using the context manager, one could look at using something like this in their tests:

http://pytest.org/latest/monkeypatch.html#example-preventing-requests-from-remote-operations

This is specifically for py.test and requests, but the idea could be extended to use mock and other HTTP libraries, as needed.

from vcrpy.

kevin1024 avatar kevin1024 commented on May 17, 2024

As a bystander unfamiliar with the Ruby version, I thought that maybe this feature was to raise an error if using the context manager and the cassette file wasn't present.

Sort of. The Ruby version doesn't really have a context manager like VCR.py does, and does all its monkeypatching when importing the package. From the docs:

Usually, HTTP requests made when no cassette is inserted will result in an error

VCR.py's context managers are kind of like Ruby VCR's cassette being inserted.

I thought that maybe this feature was to raise an error if using the context manager and the cassette file wasn't present.

I think this is possible if you use the "none" record mode. If the request hasn't been made before, it will fail with an error. Actually the cassette file can be present as long as it doesn't have the request in it, and it should still fail.

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.