Skip to content

How a story runs when it is successful - i.e. when no exception is raised during its run.

Code Example


Create files:
    - Create file
    - Create file: step2.txt
    - Create file:
        file name: step3.txt
        content: third step

from hitchstory import BaseEngine

class Engine(BaseEngine):
    def create_file(self, file_name="step1.txt", content="example"):
        with open(file_name, 'w') as handle:

    def on_success(self):
        print("splines reticulated")

        with open("ranstory.txt", 'w') as handle:

With code:

from hitchstory import StoryCollection
from pathlib import Path
from engine import Engine
StoryCollection(Path(".").glob("*.story"), Engine()).named("Create files").play()

Will output:

RUNNING Create files in /path/to/working/example.story ... splines reticulated
SUCCESS in 0.1 seconds.

File step1.txt should now contain:


File step2.txt should now contain:


File step3.txt should now contain:

third step

File ranstory.txt should now contain:

Create files

Executable specification

Documentation automatically generated from success.story storytests.