Skip to main content

Quickly create sample objects from data.

Project description

Docs PyPI Git CI

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, nest

samples = Collection({
    ClassOne: {'x': 1, 'y': 2},
    ClassTwo: {'a': 1, 'b': nest(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-4.0.0.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

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

chide-4.0.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chide-4.0.0.tar.gz
  • Upload date:
  • Size: 32.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chide-4.0.0.tar.gz
Algorithm Hash digest
SHA256 499b379fff482a0b507f91b78d704791ca10089299c2473d49cf4f46d2fe0347
MD5 ccbd8ff498d7fd1991088e5a4ed75ecb
BLAKE2b-256 daa0d3c33e24f38bba2642c4e712cae183764414688cc9d55baf9bedf40e7acb

See more details on using hashes here.

Provenance

The following attestation bundles were made for chide-4.0.0.tar.gz:

Publisher: release.yml on cjw296/chide

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: chide-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chide-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76804db9ad4c66cb4cc38564efa87013750817f18139d84be05940c931375222
MD5 4f330bd7fbbfdaaff748478f5c580107
BLAKE2b-256 481d5e9aea0dda196fb5852989531533f54e6f465463fae63d2147b5e544784f

See more details on using hashes here.

Provenance

The following attestation bundles were made for chide-4.0.0-py3-none-any.whl:

Publisher: release.yml on cjw296/chide

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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