예제 #1
0
def test_splitparen_error(monkeypatch):
    '''Test that if the first argument of the splitparen is not empty then
    an error is returned.

    '''

    monkeypatch.setattr("fparser.common.splitline.splitparen",
                        lambda x: ["XXX", "", ""])
    with pytest.raises(NoMatchError) as excinfo:
        dummy_ = Submodule_Stmt("submodule (id) name")
    assert "Submodule_Stmt: 'submodule (id) name'" in str(excinfo.value)
예제 #2
0
def test_simple_error7(f2008_create, monkeypatch):
    '''Test the parsing of a submodule statement when there is a single
    right hand bracket. The error generated here is unreachable if
    splitparen works correctly so we need to monkeypatch.

    '''

    monkeypatch.setattr("fparser.common.splitline.splitparen",
                        lambda x: ["", "id)", "name"])
    with pytest.raises(NoMatchError) as excinfo:
        dummy_ = Submodule_Stmt("submodule id) name")
    assert "Submodule_Stmt: 'submodule id) name'" in str(excinfo.value)
예제 #3
0
def test_simple_error6(f2008_create):
    ''' Test the parsing of a submodule statement'''
    with pytest.raises(NoMatchError) as excinfo:
        dummy_ = Submodule_Stmt("submodule (id) (name)")
    assert "Submodule_Stmt: 'submodule (id) (name)'" in str(excinfo.value)
예제 #4
0
def test_simple(f2008_create):
    ''' Test the parsing of a submodule statement'''
    result = Submodule_Stmt("submodule (id) name")
    assert str(result) == "SUBMODULE (id) name"