Pro test fixture configurator
Project description
protestr
protestr
is a pro test fixture configurator for Python.
Installation
pip install protestr
Usage
Create a fixture
from protestr import provide
from protestr.specs import between
@provide(
lat=between(-90.0, 90.0),
lon=between(-180.0, 180.0),
alt=float
)
def location(lat, lon, alt):
return lat, lon, alt
Call it
lat, lon, alt = location() # no args needed
Resolve it
from protestr import resolve
lat, lon, alt = resolve(location)
Provide it
from protestr import provide
@provide(location)
def test_loc(loc):
lat, lon, alt = loc
More examples
from protestr import provide
from protestr.specs import between, sequence, either, subset
import json
class TestUsage(unittest.TestCase):
@provide(
people=sequence(
each={
"id": str,
"name": either("John Smith", "Jane Doe"),
"hobbies": subset(
("cycling", "swimming", "testing with protestr"),
n=2
),
"metadata": {str: str}
},
# describe the sequence size
n=between(1, 5),
# optionally, cast to some sequence type
type=list
)
)
def test_foo(people):
print(f"people={json.dumps(people, indent=4)}")
Output
people=[
{
"id": "nFvgELbMptWisGdIDgQ",
"name": "John Smith",
"hobbies": [
"cycling",
"testing with protestr"
],
"metadata": {
"EzUnRmbjxngaIz": "sOQZTiGXzXapAwoztrdCKSQwmCaTYaK"
}
},
{
"id": "qczkMMUzgEshkpMfPkbhmSQTgb",
"name": "Jane Doe",
"hobbies": [
"swimming",
"testing with protestr"
],
"metadata": {
"spMfIaRiXOkrXqhpBWMtBui": "MJwtFAnlIRpjJOFKVxDqVL"
}
}
]
License
protestr
is distributed under the terms of the MIT license.
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
protestr-1.0.0.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file protestr-1.0.0.tar.gz
.
File metadata
- Download URL: protestr-1.0.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9aa657ad2b74eea1542e57db15ad8ce74282d19e778f69558a6c03fc2d59aec |
|
MD5 | 696fcad6a7b093c1eb2eee513cb65feb |
|
BLAKE2b-256 | 0d15d7ab9af0d6941386cc1a630bb6f73f6026bf5a5fcc89a719a54b260afd5b |
File details
Details for the file protestr-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: protestr-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2c090c23d4dd87c4f9c97e8b600c902f1841138322ac5968199f0dce9aee724 |
|
MD5 | ca9cc358781fdaa23341536a0515b27c |
|
BLAKE2b-256 | 9d54695a8c25e333d070c88990734ae9d0cf656478b670afb0dae6f362b5a464 |