Skip to main content

ycontract

PyPI PyPI - Python Version pipeline status coverage report PyPI - License

Python library for contracts testing.

This library provides functions for checking argument(in_contract) and return value(out_contract) of a function.

How to install

$ pip install ycontract

Example

Example files are here(test file)

Main example is

from ycontract import contract, out_contract

@contract(lambda a, b: a * b > 0)
def add(a, b, c):
    return a + b


@contract(returns=lambda res: res > 0)
def sub(a, b):
    return a - b

And more complex example about in_contract is

@contract(
    lambda a0: a0 > 0,
    lambda a1, b: a1 > 0 and b > 0,
    {
        "a2": lambda x: x > 0,
        "a3": [
            lambda x: x >= 0,
            lambda x: x < 4,
        ],
        ("a4", "a5"): lambda x, y: x > 0 and y > 0,
    },
    b=lambda x: x > 0,
    contract_tag="tagtag",
)
def add_for_complex(a0, a1, a2, a3, a4, a5, b=1):
    return a0 + a1 + a2 + a3 + a4 + a5 + b

Furthermore if you want to be disable, call

ycontract.disable_contract()

LICENSES

Apache 2.0

Download files

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

Source Distribution

ycontract-0.3.3.2.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

ycontract-0.3.3.2-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file ycontract-0.3.3.2.tar.gz.

File metadata

  • Download URL: ycontract-0.3.3.2.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.9.0b5 Darwin/19.3.0

File hashes

Hashes for ycontract-0.3.3.2.tar.gz
Algorithm Hash digest
SHA256 dfe0859180ad94825f7e0a858c3425d698a24d4b1646b421930d0b4d3bdbb46a
MD5 6e76ca436ec91fb33b4e876c5158e412
BLAKE2b-256 a6dc3e175a2908c92187303174d6c4754b059b7261beb2e2a4a4eb2566355890

See more details on using hashes here.

File details

Details for the file ycontract-0.3.3.2-py3-none-any.whl.

File metadata

  • Download URL: ycontract-0.3.3.2-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.9.0b5 Darwin/19.3.0

File hashes

Hashes for ycontract-0.3.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bb9770cdc2cc4d895b5a41d49d5283369525176928fa8d770a0e582dad48985e
MD5 2337e9fa075a648d15722d4177c0e5ad
BLAKE2b-256 5688ef09a5688d219cd70a924328eda74113b530ae31fa30194f2d57a3b264b6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.3.2 This release

2 files

0.3.3.1

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7.3

2 files

0.2.7.2

2 files

0.2.7.1

2 files

0.2.7

2 files

0.2.6.1

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1.2

2 files

0.2.1.1

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Supported by

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