{"id":28537536,"url":"https://github.com/python-trio/hypothesis-trio","last_synced_at":"2025-07-08T07:31:58.490Z","repository":{"id":45447763,"uuid":"141169931","full_name":"python-trio/hypothesis-trio","owner":"python-trio","description":"Hypothesis plugin for trio","archived":false,"fork":false,"pushed_at":"2021-12-13T12:46:22.000Z","size":106,"stargazers_count":7,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-09T18:11:31.668Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/python-trio.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-16T17:17:53.000Z","updated_at":"2024-11-28T16:34:00.000Z","dependencies_parsed_at":"2022-07-15T15:17:26.868Z","dependency_job_id":null,"html_url":"https://github.com/python-trio/hypothesis-trio","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/python-trio/hypothesis-trio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-trio%2Fhypothesis-trio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-trio%2Fhypothesis-trio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-trio%2Fhypothesis-trio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-trio%2Fhypothesis-trio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-trio","download_url":"https://codeload.github.com/python-trio/hypothesis-trio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-trio%2Fhypothesis-trio/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260748951,"owners_count":23056653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-09T18:10:11.868Z","updated_at":"2025-07-08T07:31:58.484Z","avatar_url":"https://github.com/python-trio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"===============\nhypothesis-trio\n===============\n\n.. image:: https://github.com/python-trio/hypothesis-trio/actions/workflows/ci.yml/badge.svg?branch=master\n    :target: https://github.com/python-trio/hypothesis-trio/actions/workflows/ci.yml\n\n.. image:: https://codecov.io/gh/python-trio/hypothesis-trio/branch/master/graph/badge.svg\n  :target: https://codecov.io/gh/python-trio/hypothesis-trio\n\nWelcome to `hypothesis-trio \u003chttps://github.com/python-trio/hypothesis-trio\u003e`__!\n\nHypothesis supports Trio out of the box for non-stateful tests.\nThis project aims at supporting the stateful mode ;-)\n\nLicense: Your choice of MIT or Apache License 2.0\n\n\nUsage\n=====\n\nReplace ``hypothesis.stateful.RuleBasedStateMachine`` by ``hypothesis_trio.stateful.TrioRuleBasedStateMachine``:\n\n.. code-block:: python\n\n    from hypothesis_trio.stateful import Bundle, TrioRuleBasedStateMachine, run_state_machine_as_test\n\n\n    def test_trio_number_modifier(hypothesis_settings):\n        class NumberModifier(TrioRuleBasedStateMachine):\n\n            folders = Bundle('folders')\n            files = Bundle('files')\n\n            @initialize(target=folders)\n            async def init_folders(self):\n                await trio.sleep(0)\n                return '/'\n\n            @rule(target=folders, name=name_strategy)\n            async def create_folder(self, parent, name):\n                await trio.sleep(0)\n                return '%s/%s' % (parent, name)\n\n            @rule(target=files, name=name_strategy)\n            async def create_file(self, parent, name):\n                await trio.sleep(0)\n                return '%s/%s' % (parent, name)\n\n            async def teardown(self):\n                await trio.sleep(0)\n\n        run_state_machine_as_test(NumberModifier, settings=hypothesis_settings)\n\n\nSupport for Trio-Asyncio\n=========================\n\n\n`trio-asyncio \u003chttps://github.com/python-trio/trio-asyncio\u003e`__ allows to mix asyncio and trio code altogether.\nTo support it in your test, you should use ``hypothesis_trio.stateful.TrioAsyncioRuleBasedStateMachine``:\n\n.. code-block:: python\n\n    class CheckAsyncioLoop(TrioAsyncioRuleBasedStateMachine):\n\n        @initialize()\n        async def initialize(self):\n            assert self.get_asyncio_loop() == asyncio.get_event_loop()\n            await trio_asyncio.aio_as_trio(lambda: asyncio.sleep(0))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-trio%2Fhypothesis-trio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-trio%2Fhypothesis-trio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-trio%2Fhypothesis-trio/lists"}