Skip to main content

Quickly create sample objects from data.

Project description

CircleCI Docs

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.0.0.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

chide-3.0.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file chide-3.0.0.tar.gz.

File metadata

  • Download URL: chide-3.0.0.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for chide-3.0.0.tar.gz
Algorithm Hash digest
SHA256 9de43af61e3816e2ed2ab9c2c76c620bfa3bc60c5cf209399375e7750026ca68
MD5 a6f3a80c63f2719b4571e8b4297aa06d
BLAKE2b-256 4acc085e430f2459c6decdb6048538c78b98c9062da7e427de617c3e9d113b35

See more details on using hashes here.

File details

Details for the file chide-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: chide-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for chide-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 406d73a56735713cfb13b199b0894491a95cc17b2820ff7a051028634b71294a
MD5 52a3bbcbf42cf2df48edb5220de50fe3
BLAKE2b-256 fd0606c03d91af9938700528a34db4b8a0825653bd4de3e9ebc27e7a6fc8c37d

See more details on using hashes here.

Supported by

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