def test_should_format_logicals(self): data = nml.tostring(True) result = ".TRUE." self.assertEqual(data.upper(), result)
def test_should_not_format_string_of_list_data(self): for input in ["1 2 3", "1, 2, 3", ".TRUE. .FALSE."]: case = nml.tostring(input) self.assertEqual(case, input)
def test_should_format_numbers(self): data = nml.tostring(self.num) result = str(self.num) self.assertEqual(data, result)
def test_should_not_format_numeric_string(self): input = "3.14159" self.assertEqual(nml.tostring(input), input)
def test_should_format_strings(self): data = nml.tostring(self.char) result = "'%s'" % (self.char, ) self.assertEqual(data, result)
def test_should_format_character_list(self): data = nml.tostring(self.char_list) result = "'a.nc', 'b.nc', 'c.nc'" self.assertEqual(data, result)
def test_should_format_numeric_list(self): data = nml.tostring(self.num_list) result = "1 3 7" self.assertEqual(data, result)
def test_should_format_mixed_list(self): data = nml.tostring(self.mixed_list) result = "'foo.nc', -1, .TRUE." self.assertEqual(data, result)
def test_should_not_format_numeric_string(self): input = "3.14159" self.assertEqual(nml.tostring(input), input) def test_should_format_logicals(self): data = nml.tostring(True) result = ".TRUE." self.assertEqual(data.upper(), result) def test_should_not_format_string_of_list_data(self): for input in ["1 2 3", "1, 2, 3", ".TRUE. .FALSE."]: case = nml.tostring(input) self.assertEqual(case, input) def test_should_treat_mixed_numeric_character_data_as_character(self): case = nml.tostring(self.mixed_str_list) result = "'foo.nc', '-1', '.TRUE.'" self.assertEqual(case, result) class TestUpdateNamelist(unittest.TestCase): def setUp(self): self.empty = """ &namone / """ self.single = """ &namone x = 'y' / """