Beispiel #1
0
    def use_cassette(path, return_body=None, **kwargs):
        """Adapter so we could create/use custom use_cassette with custom parameters

        Parameters
        ----------
        path : str
          If not absolute path, treated as a name for a cassette under fixtures/vcr_cassettes/
        """
        path = _get_cassette_path(path)
        lgr.debug("Using cassette %s" % path)
        if return_body is not None:
            my_vcr = _VCR(before_record_response=lambda r: dict(r, body={'string': return_body.encode()}))
            return my_vcr.use_cassette(path, **kwargs)  # with a custom response
        else:
            return _use_cassette(path, **kwargs)  # just a straight one
Beispiel #2
0
    def use_cassette(path, return_body=None, **kwargs):
        """Adapter so we could create/use custom use_cassette with custom parameters

        Parameters
        ----------
        path : str
          If not absolute path, treated as a name for a cassette under fixtures/vcr_cassettes/
        """
        path = _get_cassette_path(path)
        lgr.debug("Using cassette %s" % path)
        if return_body is not None:
            my_vcr = _VCR(before_record_response=lambda r: dict(
                r, body={'string': return_body.encode()}))
            return my_vcr.use_cassette(path,
                                       **kwargs)  # with a custom response
        else:
            return _use_cassette(path, **kwargs)  # just a straight one