Skip to content

Example statemachine only runs 1 example. #14

Open
@eivindjahren

Description

@eivindjahren

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions