Quickly create sample objects from data.
Project description
Quickly create and compare sample objects.
Chide’s philosophy is to give you a simple registry of parameters needed to instantiate objects for your tests. There’s also support for simplifying objects down to mappings of their attributes for easier comparison and rendering, along with parsing and rendering of formats for inserting or asserting about multiple objects that are naturally tabular.
Quickstart
Say we have two classes that each require two parameters in order to be instantiated:
from dataclasses import dataclass
@dataclass
class ClassOne:
x: int
y: int
@dataclass
class ClassTwo:
a: int
b: ClassOne
We can set up a registry of sample values as follows:
from chide import Collection
samples = Collection({
ClassOne: {'x': 1, 'y': 2},
ClassTwo: {'a': 1, 'b': ClassOne},
})
Now we can quickly make sample objects:
>>> samples.make(ClassOne) ClassOne(x=1, y=2)
We can provide our own overrides if we want:
>>> samples.make(ClassOne, y=3) ClassOne(x=1, y=3)
We can also create nested trees of objects:
>>> samples.make(ClassTwo) ClassTwo(a=1, b=ClassOne(x=1, y=2))
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 chide-3.2.0.tar.gz.
File metadata
- Download URL: chide-3.2.0.tar.gz
- Upload date:
- Size: 32.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
964a6282539c93d46971b154c19f3869c140816ea500238c20c24fd0858d2084
|
|
| MD5 |
c9fbf23630534ae4e3f094f71441d59f
|
|
| BLAKE2b-256 |
9a56c2d80629774d8d282315ae6fb9177b3d3cc01c86e77bbd039a452858bb66
|
File details
Details for the file chide-3.2.0-py3-none-any.whl.
File metadata
- Download URL: chide-3.2.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12636fef0eac85117ddfc6278b5587d9555252e38e9d012c8f07d7d61e728a89
|
|
| MD5 |
a108e15cdfbb14400a9d973ce2b29eed
|
|
| BLAKE2b-256 |
f9b5556bd257f8214df45b25b9a3b10de3f6f9bbdab56c6846bc1b351dc4f0e6
|