Пример #1
0
def test_createvarname_unknown_content():
    '''Test that if the create_var_name function does not recognise
    content within the parse tree passed to it, then it raises an
    exception in the expected way.

    '''
    with pytest.raises(InternalError) as excinfo:
        _ = create_var_name("invalid")
    assert "unrecognised structure" in str(excinfo.value)
Пример #2
0
def test_createvarname_error1():
    '''Test that if the create_var_name function does not recognise
    content within the parse tree passed to it, then it raises an
    exception in the expected way.

    '''
    name = "class"
    if six.PY2:
        name = "type"
    with pytest.raises(InternalError) as excinfo:
        _ = create_var_name("invalid")
    assert ("algorithm.py:create_var_name unrecognised structure "
            "'<{0} 'str'>'".format(name) in str(excinfo.value))
Пример #3
0
def test_createvarname_error2(monkeypatch):
    '''Test that if the create_var_name function does not recognise
    content within a Data_Ref passed to it, then it raises an
    exception in the expected way.

    '''
    name = "class"
    if six.PY2:
        name = "type"
    content = Data_Ref("a%b")
    monkeypatch.setattr(content, "items", ["invalid", "invalid"])
    with pytest.raises(InternalError) as excinfo:
        _ = create_var_name(content)
    assert ("algorithm.py:create_var_name unrecognised structure "
            "'<{0} 'str'>' in '<class 'fparser.two.Fortran2003."
            "Data_Ref'>'".format(name) in str(excinfo.value))
Пример #4
0
def test_createvarname(expression, expected):
    '''Test that create var name works as expected (for cases with Name,
    Part_Ref, Data_Ref and Proc_Component_Ref).

    '''
    assert create_var_name(expression) == expected