Esempio n. 1
0
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')
Esempio n. 2
0
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()
Esempio n. 3
0
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())
Esempio n. 4
0
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()
Esempio n. 5
0
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()
Esempio n. 6
0
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)
Esempio n. 7
0
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
Esempio n. 8
0
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