Skip to main content

Quickly create sample objects from data.

Project description

Docs PyPI Git CircleCI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chide-3.2.0.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chide-3.2.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

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

Hashes for chide-3.2.0.tar.gz
Algorithm Hash digest
SHA256 964a6282539c93d46971b154c19f3869c140816ea500238c20c24fd0858d2084
MD5 c9fbf23630534ae4e3f094f71441d59f
BLAKE2b-256 9a56c2d80629774d8d282315ae6fb9177b3d3cc01c86e77bbd039a452858bb66

See more details on using hashes here.

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

Hashes for chide-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12636fef0eac85117ddfc6278b5587d9555252e38e9d012c8f07d7d61e728a89
MD5 a108e15cdfbb14400a9d973ce2b29eed
BLAKE2b-256 f9b5556bd257f8214df45b25b9a3b10de3f6f9bbdab56c6846bc1b351dc4f0e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page