def test_GIVEN_date_WHEN_convert_THEN_date_returned(self):
     date = datetime.datetime(2012, 1, 1, 0, 0, 0)
     datestr = date.strftime("%Y-%m-%d %X")
     input = "'" + datestr + "'"
     output = f90_helper.f90_str_to_python(input)
     expected_output = date
     assert_that(output, is_(expected_output))
 def get_value_as_python(self, is_list=False):
     """
     Get the Parameter value, converting a Fortran namelist string to a Python type
     :param is_list: Indicates whether this value is a list
     :return: Python type
     """
     return f90_helper.f90_str_to_python(self.value, is_list)
 def test_GIVEN_list_of_strings_WHEN_convert_to_list_THEN_list_of_strings_returned(self):
     input = "'str1'  'str2'  'str3'"
     output = f90_helper.f90_str_to_python(input, True)
     expected_output = ["str1", "str2", "str3"]
     assert_that(output, is_(expected_output))
 def test_GIVEN_list_of_ints_WHEN_convert_to_list_THEN_list_of_ints_returned(self):
     input = '2 4 6 8 10'
     output = f90_helper.f90_str_to_python(input, True)
     expected_output = [2, 4, 6, 8, 10]
     assert_that(output, is_(expected_output))
 def test_GIVEN_scientific_WHEN_convert_THEN_float_returned(self):
     input = '3E-4'
     output = f90_helper.f90_str_to_python(input)
     expected_output = 0.0003
     assert_that(output, is_(expected_output))
     assert isinstance(output, float)
 def test_GIVEN_float_WHEN_convert_THEN_float_returned(self):
     input = '3600.0'
     output = f90_helper.f90_str_to_python(input)
     expected_output = 3600.0
     assert_that(output, is_(expected_output))
     assert isinstance(output, float)
 def test_GIVEN_bool_false_WHEN_convert_THEN_false_returned(self):
     input = '.false.'
     output = f90_helper.f90_str_to_python(input)
     assert isinstance(output, bool)
     assert (not output)
 def test_GIVEN_string_with_comma_WHEN_convert_THEN_string_returned(self):
     input = "'text string here', 'more string'"
     output = f90_helper.f90_str_to_python(input)
     expected_output = "text string here', 'more string"
     assert_that(output, is_(expected_output))
 def test_GIVEN_list_of_bools_WHEN_convert_to_list_THEN_list_of_bools_returned(self):
     input = ".false.  F f FALSE .true.  T t TRUE"
     output = f90_helper.f90_str_to_python(input, True)
     expected_output = [False, False, False, False, True, True, True, True]
     assert_that(output, is_(expected_output))