Skip to main content

Partial matching of any object

Project description

Expyct

CircleCI

Partial matching of any object. This is especially useful for testing that your functions return expected values.

Full reference can be found here.

Example:

import expyct as exp
from datetime import datetime


def test_my_function():
    result = my_function()

    assert result == {
        "first_name": exp.String(regex="(mary)|(peter)", ignore_case=True),
        "last_name": "Johnson",
        "signup_date": exp.DateTime(after=datetime(2020, 1, 2), before=datetime(2020, 3, 5)),
        "details": {
            "number": exp.Int(min=2),
            "amount": exp.Float(close_to=2.3, error=0.001),
            "purchases": exp.List(of=exp.Dict(), non_empty=True),
        },
        "time_of_purchase": exp.OneOf([exp.TODAY, exp.THIS_WEEK]),
        "type": exp.AnyType(subclass_of=str),
        "item_ids": exp.Set(subset_of=[1, 2, 3]),
        "metadata": exp.Dict(keys=exp.Collection(superset_of=["a", "b"])),
        "context": exp.ANY,
    }

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

expyct-0.2.0.tar.gz (8.8 kB view hashes)

Uploaded Source

Built Distribution

expyct-0.2.0-py3-none-any.whl (10.9 kB view hashes)

Uploaded Python 3

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