scrapy_tdd
Helpers and examples to build Scrapy Crawlers in a test driven way.
Motivation / Why should I develop Scrapy Crawlers using TDD?
The develop - test cycle goes down to a few seconds and so it allows you to get a properly working scraper up much faster
When bugs are discovered in “the wild” with real data, new example files, a test and a fix can be created and tested much faster
It allows for fast refactoring without breaking anything - which results in much cleaner scraper code
It just feels right when you are used to be doing TDD
What’s the difference to Scrapy’s Spiders Contracts?
Scrapy has its own builtin testing feature named Spiders Contracts
I tried to use them for some time, but decided to build real unit tests in a unit test framework like py.test because of these shortcomings:
its philosophy is geared towards testing against contracts (thus the name) that by nature are more broad and less specific concepts. Testing for exact field contents in items can be done, but is difficult and fragile
its documentation and basic set of features is a bit thin
it mixes implementation code with contract descriptions which is only usable when there are few and simple contracts
Installation
pip install scrapy_tdd
Quick Start Examples
- def describe_fancy_spider():
to_test = MySpider().from_crawler(get_crawler())
- def describe_parse_suggested_terms():
resp = response_from(“Result_JSON_Widget.txt”) results = to_test.parse(resp)
- def should_get_item():
item = results assert item[0][“lorem”] == ‘ipsum’ assert item[0][“iterem”] == “ipsem”
Full Documentation
… coming soon …
Missing / next steps
Mocking Request-Response pairs
How to contribute
… coming soon …
Metadata
Release files for scrapy-tdd 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scrapy_tdd-0.2.0.tar.gz | 18.2 kB | Without provenance | Details for scrapy_tdd-0.2.0.tar.gz |
Release files / scrapy_tdd-0.2.0.tar.gz
| Download URL | scrapy_tdd-0.2.0.tar.gz |
|---|---|
| Size | 18.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6350b8264a9eac50973a6079fd8e3c0596f361e2d556f5f3f238d3a9c4fdc4a8
|
|
BLAKE2b-256 checksum How to use checksums |
9a47603158fc820fd25ddd43f6abb63161d39b551fdad030ffd0237a9e019594
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for scrapy-tdd 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.