betamaxpy / betamax

A VCR imitation designed only for python-requests.
https://betamax.readthedocs.io/en/latest/
Other
562 stars 61 forks source link

request was made to <url> that could not be found in html_crawler_test.TestMyHttpClient.test_get. #181

Closed ghost closed 4 years ago

ghost commented 4 years ago

I am trying to get started with betamax but I keep getting

betamax.exceptions.BetamaxError: A request was made that could not be handled.

when running the code below:

import os

import betamax
import pytest
import scrapy
from scrapy import Request

with betamax.Betamax.configure() as config:
    cassette_library_dir = '/tmp/crawler/tests/betamax/cassettes'
    if not os.path.exists(cassette_library_dir):
        os.makedirs(cassette_library_dir)
    config.cassette_library_dir = cassette_library_dir
    config.preserve_exact_body_bytes = True

the_url = 'http://doc.scrapy.org/en/latest/_static/selectors-sample1.html'

@pytest.mark.usefixtures('betamax_session')
class TestMyHttpClient:
    def test_get(self, betamax_session):
        betamax_session.get(the_url)

Any idea why I am getting this?

ghost commented 4 years ago

Never mind - I just had to clear the cache.