Skip to content

Record Scrapy responses and use them as testing fixtures.

License

Notifications You must be signed in to change notification settings

tcurvelo/scrapy-mock

Repository files navigation

scrapy-mock

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

About

Record Scrapy responses and use them as testing fixtures.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages