Check links in files
Project description
pytest-check-links
pytest plugin that checks URLs for HTML-containing files.
Supported files
.html
.rst
.md
(TODO: select renderer).ipynb
(requiresnbconvert
)
Install
pip install pytest-check-links
Use
pytest --check-links mynotebook.ipynb
Configure
--links-ext
default:
md,rst,html,ipynb
A comma-separated list of extensions to check
--check-anchors
Also check whether links with #anchors
HTML files (either local, or with
served with html
in the Content-Type
) actually exist, and point to exactly one
named anchor.
--check-links-ignore
A regular expression that matches URIs that should not be checked. Can be specified multiple times for multiple ignore patterns. This can be used for files that have a lot of links to GitHub pages, such as a Changelog. GitHub has rate limiting, which would normally cause these files to take up to an hour to complete for larger repositories. For example:
pytest --check-links --check-links-ignore "https://github.com/.*/pull/.*" CHANGELOG.md
Cache
Caching requires the installation of requests-cache
.
pip install requests-cache
If enabled, each occurance of a link will be checked, no matter how many times it appears in a collection of files to check.
--check-links-cache
Cache requests when checking links. Caching is disabled by default, and this option must be provided, even if other cache configuration options are provided.
--check-links-cache-name
default:
.pytest-check-links-cache
Name of link cache, either the base name of a file or similar, depending on backend.
--check-links-cache-backend
default:
sqlite3
Cache persistence backend. The other known backends are:
memory
redis
mongodb
See the requests-cache documentation for more information.
--check-links-cache-expire-after
default:
None
(unlimited)
Time to cache link responses (seconds).
--check-links-cache-backend-opt
Backend-specific options for link cache, provided as key:value
. These are passed
directly to the requests_cache.CachedSession
constructor, as they vary depending
on the backend.
Values will be parsed as JSON first, so to overload the default of caching all
HTTP response codes (which requires a list of int
s):
--check-links-backend-opt allowable_codes:[200]
TODO
- pick a markdown renderer (probably commonmark) or make the markdown renderer pluggable
- options for validating links (allow absolute links, only remote or local, etc.)
- find URLs in Python docstrings
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest_check_links-0.7.1.tar.gz
.
File metadata
- Download URL: pytest_check_links-0.7.1.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5c45ced56865a76d392f29892ad6af4dfba11111a87a669ca69378aeaca30eb |
|
MD5 | 347e71d27838c36a13e2757764fdecd7 |
|
BLAKE2b-256 | 01a309b3c9ccac52ad6f837ff4f3aea6fda8edad14cec1ae588ef0d72a406d7d |
Provenance
File details
Details for the file pytest_check_links-0.7.1-py3-none-any.whl
.
File metadata
- Download URL: pytest_check_links-0.7.1-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16c8a45525a683e4d3bde5b99d06834052f64b58f64f5a05a4eaf70ea31a4595 |
|
MD5 | 9b9b0e2d17103652cef32e2242dfb4b2 |
|
BLAKE2b-256 | 40b8b4623cddaa6ba3e214573fa9254c7172adfd6be5e3b0b1d0c84772120274 |