I\'d like to implement some unit tests in a Scrapy (screen scraper/web crawler). Since a project is run through the \"scrapy crawl\" command I can run it through something
Similar to Hadrien's answer but for pytest: pytest-vcr.
import requests
import pytest
from scrapy.http import HtmlResponse
@pytest.mark.vcr()
def test_parse(url, target):
response = requests.get(url)
scrapy_response = HtmlResponse(url, body=response.content)
assert Spider().parse(scrapy_response) == target