def test_bundle_lex_ebnf(patch, bundle): """ Ensures Bundle.lex supports specifying an ebnf file """ patch.object(Story, 'from_file') patch.object(Bundle, 'find_stories', return_value=['story']) bundle.lex(ebnf='ebnf') Story.from_file().lex.assert_called_with(ebnf='ebnf')
def test_bundle_lex(patch, bundle): """ Ensures Bundle.lex can lex a bundle """ patch.object(Story, 'from_file') patch.object(Bundle, 'find_stories', return_value=['story']) result = bundle.lex() Story.from_file.assert_called_with('story') Story.from_file().lex.assert_called_with(ebnf=None) assert result['story'] == Story.from_file().lex()
def test_bundle_lex_ebnf(patch, bundle): """ Ensures Bundle.lex supports specifying an ebnf file """ patch.object(Story, "from_file") patch.object(Bundle, "find_stories", return_value=["story"]) patch.object(Bundle, "parser") bundle.lex(ebnf="ebnf") Bundle.parser.assert_called_with("ebnf") Story.from_file().lex.assert_called_with(parser=Bundle.parser())
def test_bundle_lex(patch, bundle): """ Ensures Bundle.lex can lex a bundle """ patch.object(Story, 'from_file') patch.object(Bundle, 'find_stories', return_value=['story']) patch.object(Bundle, 'parser') result = bundle.lex() Story.from_file.assert_called_with('story', features=bundle.features) Bundle.parser.assert_called_with(None) Story.from_file().lex.assert_called_with(parser=Bundle.parser()) assert result['story'] == Story.from_file().lex()
def test_bundle_lex(patch, bundle): """ Ensures Bundle.lex can lex a bundle """ patch.object(Story, "from_file") patch.object(Bundle, "find_stories", return_value=["story"]) patch.object(Bundle, "parser") result = bundle.lex() Story.from_file.assert_called_with("story", features=bundle.features) Bundle.parser.assert_called_with(None) Story.from_file().lex.assert_called_with(parser=Bundle.parser()) assert result["story"] == Story.from_file().lex()
def test_story_from_file(patch): patch.init(Story) patch.object(Story, 'read') result = Story.from_file('hello.story', features=None) Story.read.assert_called_with('hello.story') Story.__init__.assert_called_with(Story.read(), None, path='hello.story') assert isinstance(result, Story)
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 test_exception_file_not_found(capsys): with raises(StoryError) as e: Story.from_file('this-file-does-not-exist') message = e.value.message() assert 'File "this-file-does-not-exist" not found at' in message