def test_fortranformat_from_mode(mode): #pylint: disable=redefined-outer-name ''' Tests that the object is correctly created by the from_mode function. ''' unit_under_test = FortranFormat.from_mode(mode[0]) assert unit_under_test.mode == mode[0] assert unit_under_test.is_free == mode[1] assert unit_under_test.is_fixed == (not mode[1]) assert unit_under_test.is_strict == mode[2] assert unit_under_test.is_f77 == (not mode[1] and mode[2]) assert unit_under_test.is_fix == (not mode[1] and not mode[2]) assert unit_under_test.is_pyf == (mode[1] and mode[2]) assert str(unit_under_test.mode) == mode[0]
def test_format_from_mode_bad(): ''' Tests that an exception is thrown for an unrecognised mode string. ''' with pytest.raises(NotImplementedError): _unit_under_test = FortranFormat.from_mode('cheese')