Python test utils
Project description
tested
General python testing utils
To install: pip install tested
A little tour...
validate_codec
Let's start with validate_codec, a function to test encoder/decoder pairs.
>>> from tested import validate_codec
pickle.dumps/pickle.loads is the default encoder/decoder pair.
You can pickle lists, and datetime objects
>>> validate_codec([1, 2, 3])
True
>>> from datetime import datetime
>>> validate_codec(datetime.now())
True
But you can't pickle a lambda function
>>> validate_codec(lambda x: x)
False
>>> from functools import partial
>>> import json
>>> validate_jsonability = partial(validate_codec, coder=json.dumps, decoder=json.loads)
You can jsonize lists and dicts
>>> assert validate_jsonability([1, 2, 3])
>>> assert validate_jsonability({'a': 1, 'b': {'c': [1, 2, 3]}})
You can't jsonize datetime objects
>>> from datetime import datetime
>>> validate_jsonability(datetime.now())
False
See validate_codec docs
for more examples.
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
tested-0.1.24.tar.gz
(17.0 kB
view details)
File details
Details for the file tested-0.1.24.tar.gz.
File metadata
- Download URL: tested-0.1.24.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d680f5382b16a615accb8e4ac262794555149f43277dae9e963cc74861f31e4
|
|
| MD5 |
b71f6667a2e0eda9bd7d9bd97a77d3de
|
|
| BLAKE2b-256 |
05414849b14f6d43907c1a8dc9fd8b15d958052db193d79b7bc9a3a7827bad8f
|