Example #1
0
def test_arg_datatype():
    '''Check that the datatype argument defaults to None and that any
    datatype content is stored correctly.

    '''
    tmp = Arg("literal", "0.0")
    assert tmp._datatype is None
    tmp = Arg("variable", "var", varname="var", datatype=("info"))
    assert tmp._datatype == ("info")
Example #2
0
def test_arg_str():
    '''Test that the __str__ method in Arg() behaves as expected'''

    # without the optional varname argument
    tmp = Arg("literal", "0.0")
    assert str(tmp) == "Arg(form='literal',text='0.0',varname='None')"

    # with the optional varname argument
    tmp = Arg("indexed_variable", "my_arg(2)", "my_arg")
    assert str(tmp) == ("Arg(form='indexed_variable',text='my_arg(2)',"
                        "varname='my_arg')")
Example #3
0
def test_arg_unknown():
    '''Test that an exception is raised correctly if an invalid arg type
    is provided to the Arg() form argument.

    '''
    with pytest.raises(InternalError) as excinfo:
        _ = Arg("invalid", "0.0")
    assert (
        "Unknown arg type provided. Expected one of ['literal', 'variable', "
        "'indexed_variable'] but found 'invalid'.") in str(excinfo.value)