def story(): return Story('story', features=None)
def test_exceptions_file_not_found(capsys): with raises(StoryError) as e: Story.from_file('this-file-does-not-exist', Features(None)) message = e.value.message() assert 'File `this-file-does-not-exist` not found at' in message
def story_format(source): return Story(source, features={}).parse(parser=None).format()
def test_story_read_not_found(patch, capsys): patch.object(io, 'open', side_effect=FileNotFoundError) patch.object(os, 'path') with raises(StoryError) as e: Story.read('whatever') assert 'E0001: File "whatever" not found at ' in e.value.short_message()
def run_story(text): features = Features(None) return Story(text, features).process()
def test_story_init_path(): story = Story('story', path='path') assert story.path == 'path'
def story(): return Story('story')
def test_story_from_stream(patch, magic): patch.init(Story) stream = magic() result = Story.from_stream(stream, features=None) Story.__init__.assert_called_with(stream.read(), None) assert isinstance(result, Story)
def test_story_init_path(): story = Story('story', features=None, path='path') assert story.path == 'path'
def test_story_from_stream(): stream = StringIO('x = 0') story = Story.from_stream(stream, features=None) assert story.story == 'x = 0'