How a story runs when it is successful - i.e. when no exception is raised during its run.
Create files: steps: - 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: handle.write(content) def on_success(self): print("splines reticulated") with open("ranstory.txt", 'w') as handle: handle.write(self.story.name)
from hitchstory import StoryCollection from pathlib import Path from engine import Engine
StoryCollection(Path(".").glob("*.story"), Engine()).named("Create files").play()
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:
File ranstory.txt should now contain:
Documentation automatically generated from success.story storytests.