Skip to main content

hypothesis-trio

https://github.com/python-trio/hypothesis-trio/actions/workflows/ci.yml/badge.svg?branch=master https://codecov.io/gh/python-trio/hypothesis-trio/branch/master/graph/badge.svg

Welcome to hypothesis-trio!

Hypothesis supports Trio out of the box for non-stateful tests. This project aims at supporting the stateful mode ;-)

License: Your choice of MIT or Apache License 2.0

Usage

Replace hypothesis.stateful.RuleBasedStateMachine by hypothesis_trio.stateful.TrioRuleBasedStateMachine:

from hypothesis_trio.stateful import TrioRuleBasedStateMachine, run_state_machine_as_test


def test_trio_number_modifier(hypothesis_settings):
    class NumberModifier(TrioRuleBasedStateMachine):

        folders = Bundle('folders')
        files = Bundle('files')

        @initialize(target=folders)
        async def init_folders(self):
            await trio.sleep(0)
            return '/'

        @rule(target=folders, name=name_strategy)
        async def create_folder(self, parent, name):
            await trio.sleep(0)
            return '%s/%s' % (parent, name)

        @rule(target=files, name=name_strategy)
        async def create_file(self, parent, name):
            await trio.sleep(0)
            return '%s/%s' % (parent, name)

        async def teardown(self):
            await trio.sleep(0)

    run_state_machine_as_test(NumberModifier, settings=hypothesis_settings)

Support for Trio-Asyncio

trio-asyncio allows to mix asyncio and trio code altogether. To support it in your test, you should use hypothesis_trio.stateful.TrioAsyncioRuleBasedStateMachine:

class CheckAsyncioLoop(TrioAsyncioRuleBasedStateMachine):

    @initialize()
    async def initialize(self):
        assert self.get_asyncio_loop() == asyncio.get_event_loop()
        await trio_asyncio.aio_as_trio(lambda: asyncio.sleep(0))

Metadata

Release files for hypothesis-trio 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hypothesis-trio 0.6.0
File Size Uploaded Provenance Actions
hypothesis-trio-0.6.0.tar.gz 19.6 kB Without provenance Details for hypothesis-trio-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hypothesis-trio 0.6.0
File Interpreter ABI Platform Actions
hypothesis_trio-0.6.0-py3-none-any.whl Python 3 none any Details for hypothesis_trio-0.6.0-py3-none-any.whl

Total release size: 35.3 kB

Release files / hypothesis-trio-0.6.0.tar.gz

Download URL hypothesis-trio-0.6.0.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d7ab108ac99758011b20f2448f1b1269375c68c1ffda9e4468600a4975ff955c
BLAKE2b-256 checksum
How to use checksums
2578007b68f95bba5854a99a106a2e2197478320a80c0abfa4c17d40d46c4b66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.2.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

Release files / hypothesis_trio-0.6.0-py3-none-any.whl

Download URL hypothesis_trio-0.6.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ac261dc6fcf3862d7d57ffa52d294539f8d807ac9483d58a8060df3c9e856fc
BLAKE2b-256 checksum
How to use checksums
cf2bb22113f2076b5e733a2d69ba3e28397f42e09b884df69ecac1cfaa33e221
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.2.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

Security for hypothesis-trio 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page