Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example statemachine only runs 1 example. #14

Open
eivindjahren opened this issue Feb 9, 2024 · 0 comments
Open

Example statemachine only runs 1 example. #14

eivindjahren opened this issue Feb 9, 2024 · 0 comments

Comments

@eivindjahren
Copy link

eivindjahren commented Feb 9, 2024

After fiddling around to get the example given in the README to work, it seems to only run one example using hypothesis version 6.98.1:

import hypothesis.strategies as st
import trio
from hypothesis import Verbosity, settings
from hypothesis_trio.stateful import (
    Bundle,
    TrioAsyncioRuleBasedStateMachine,
    initialize,
    rule,
    run_state_machine_as_test,
)


def test_trio_number_modifier():
    class NumberModifier(TrioAsyncioRuleBasedStateMachine):
        folders = Bundle("folders")
        files = Bundle("files")

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

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

        @rule(target=files, name=st.text())
        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=settings(verbosity=Verbosity.debug)
    )

This shows the following output when ran with pytest -s:

test_trio.py Reusing examples from database
Trying example:
state = NumberModifier()
async def steps():
    v1 = await state.init_folders()
    await state.teardown()
state.trio_run(steps)
4 bytes [[1, 0]] -> Status.VALID, 
exit_with(finished)
Run complete after 1 examples (1 valid) and 0 shrinks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant