pytest-lock
Overview
pytest-lock is a pytest plugin that allows you to "lock" the results of unit tests, storing them in a local cache. This is particularly useful for tests that are resource-intensive or don't need to be run every time. When the tests are run subsequently. pytest-lock will compare the current results with the locked results and issue a warning if there are any discrepancies.
- Free software: Apache license
- Documentation: https://pytest-lock.readthedocs.io/en/latest/
- Source: https://github.com/Athroniaeth/pytest-lock
- Bugs: https://github.com/Athroniaeth/pytest-lock/issues
- Contributing: https://github.com/Athroniaeth/pytest-lock/blob/main/CONTRIBUTING.md
Installation
To install pytest-lock, you can use pip:
pip install pytest-lock
Usage
Locking Tests
To lock a test, use the lock fixture. Here's an example:
from pytest_lock import FixtureLock
def test_lock_sum(lock: FixtureLock):
args = [1, 2, 3]
lock.lock(sum, (args,))
...
Run pytest with the --lock option to generate the lock files:
pytest --lock
This will generate JSON files in a .pytest-lock directory, storing the results of the locked tests.
Running Tests
Simply run pytest as you normally would:
pytest
If pytest detect the presence of lock fixtures in your tests, it will compare the results of the tests with the locked If a test result differs from its locked value, a warning will be issued.
Configuration
The locked test results are stored in a .pytest-lock directory at the root of your project. You can delete this
directory to reset all locks.
Contributing
Contributions are welcome! Please read the contributing guidelines to get started.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Metadata
Release files for pytest-lock 1.0.1
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 |
|---|---|---|---|---|
| pytest_lock-1.0.1.tar.gz | 13.9 kB | Without provenance | Details for pytest_lock-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_lock-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for pytest_lock-1.0.1-py3-none-any.whl |
Total release size: 34.3 kB
Release files / pytest_lock-1.0.1.tar.gz
| Download URL | pytest_lock-1.0.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f499a4b8f46202eeccaa789528c829a3efda0429a94d8c569d910d078e8e867
|
|
BLAKE2b-256 checksum How to use checksums |
eaecbb8bca2d62d1e3aee6b7a8d469958ff740aec72b16e8c915c1de7a107df9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1019-azure
|
Release files / pytest_lock-1.0.1-py3-none-any.whl
| Download URL | pytest_lock-1.0.1-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c73dcb563c4fee3d9b799434bd7f7f67dc6407627f67813ed6e0d4207c3d03f3
|
|
BLAKE2b-256 checksum How to use checksums |
7df42460ba60d060bb91f67c8ec3b27b5ae3643e82f9759ac0fe1e880d1a8856
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1019-azure
|
Security for pytest-lock 1.0.1
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.