Skip to main content

A Pytest plugin to record Scrapy responses and use them as testing fixtures.

Project description

A Pytest plugin to record Scrapy responses and use them as testing fixtures. The motivation here is to decrease the friction to write unit tests for Scrapy spiders.

Install

pip install scrapy-mock

Usage

@pytest.mark.parametrize(
    ["url", "expected"],
    ("http://foobar.com/item/1",  {"name": "item1", "url": "/item/1"}),
])
def test_parse(spider, response, expected):
    result = next(spider.parse(response))
    assert result == expected

Project details


Release history Release notifications

This version

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for scrapy-mock, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size scrapy-mock-0.1.0.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page