Type-safe and maintainable fixtures and parametrization for pytest.
Project description
pytypest
Type-safe and maintainable fixtures and parametrization for pytest.
Features:
- 100% type safe.
- Great IDE integration, go-to-definition always takes you in the right place.
- Test parametrization that is readable even with many arguments.
- Plug-and-play integration with pytest.
- No vendor-lock, you can use only the features you need and don't touch the rest.
- Fixtures can be cached, and you are in control of for how long.
- Fixtures can accept arguments.
Check out motivation if you want to know more about why this project was born.
Installation
python3 -m pip install pytypest
Usage
Fixtures are regular helper functions that yield their result and do teardown afterwards:
from typing import Iterator
from pytypest import fixture
@fixture
def get_user(anonymous: bool) -> Iterator[User]:
u = User(anonymous=anonymous)
u.save()
yield u
u.delete()
def test_user() -> None:
u = get_user(anonymous=False)
assert u.anonymous is False
Compared to built-in pytest fixtures, these are explicit, type-safe, can accept arguments, support go-to-definition in IDE, and can be used as context managers. And like pytest fixtures, they are cached and can be scoped to the module or the whole session.
Read more in the documentation: pytypest.orsinium.dev.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytypest-1.0.1.tar.gz.
File metadata
- Download URL: pytypest-1.0.1.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
184653886cccfa2c9459554f2dbc9bdb7e76841338dd1e2092fa8ff21bf22991
|
|
| MD5 |
fba2c5039e7275fc1c62eb6d5112cad1
|
|
| BLAKE2b-256 |
65114f309c036be5f764dc4cfd0cebcaa16c7a7f5950c0b78814bff63108b84c
|
File details
Details for the file pytypest-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pytypest-1.0.1-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1688279605bc4458fa8154cd85ec8df5c242e036a42adf481a4bb93ba567b76
|
|
| MD5 |
1a43526ed75baed11b6d6a335bb32795
|
|
| BLAKE2b-256 |
c0fb845f41a62d4952d8713ce6e10a055f7cf799dca48a84999c1b9012406bde
|