Ejemplo n.º 1
0
 def test_should_format_logicals(self):
     data = nml.tostring(True)
     result = ".TRUE."
     self.assertEqual(data.upper(), result)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 def test_should_format_numbers(self):
     data = nml.tostring(self.num)
     result = str(self.num)
     self.assertEqual(data, result)
Ejemplo n.º 4
0
 def test_should_not_format_numeric_string(self):
     input = "3.14159"
     self.assertEqual(nml.tostring(input), input)
Ejemplo n.º 5
0
 def test_should_format_strings(self):
     data = nml.tostring(self.char)
     result = "'%s'" % (self.char, )
     self.assertEqual(data, result)
Ejemplo n.º 6
0
 def test_should_format_character_list(self):
     data = nml.tostring(self.char_list)
     result = "'a.nc', 'b.nc', 'c.nc'"
     self.assertEqual(data, result)
Ejemplo n.º 7
0
 def test_should_format_numeric_list(self):
     data = nml.tostring(self.num_list)
     result = "1 3 7"
     self.assertEqual(data, result)
Ejemplo n.º 8
0
 def test_should_format_mixed_list(self):
     data = nml.tostring(self.mixed_list)
     result = "'foo.nc', -1, .TRUE."
     self.assertEqual(data, result)
Ejemplo n.º 9
0
    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'
/
"""