Skip to content

Commit

Permalink
Fixed failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisjared committed Mar 6, 2018
1 parent 77e5619 commit b01ad0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tests/conf/test_parse_namelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,19 @@ def test_advanced(self):
auxinput11_end_h = 6 ; end of observation time in hours""")
self.assertEqual(get_next_item(lines), """output_diagnostics = 1 ; adds 36 surface diagnostic arrays (max/min/mean/std)""")


class TestConfigItem(TestCase):
def test_basic_parse(self):
i = ConfigItem(' time_step_fract_num = 0, ; numerator for fractional time step\n')
self.assertFalse(i.is_section)
self.assertEqual(i.name, 'time_step_fract_num')
self.assertEqual(i.default, '0,')
self.assertEqual(i.default, '0')
self.assertEqual(i.description, 'numerator for fractional time step')

def test_multiline(self):
i = ConfigItem(" e_vert (max_dom) = 30, ; end index in z (vertical) direction (staggered dimension)\n Note: this refers to full levels including surface and top\n vertical dimensions need to be the same for all nests\n Note: most variables are unstaggered (= staggered dim - 1)\n")
self.assertFalse(i.is_section)
self.assertEqual(i.name, 'e_vert')
self.assertTrue(i.is_multi_dim)
self.assertEqual(i.default, '30,')
self.assertEqual(i.default, '30')
self.assertEqual(i.description, 'end index in z (vertical) direction (staggered dimension)\nNote: this refers to full levels including surface and top\nvertical dimensions need to be the same for all nests\nNote: most variables are unstaggered (= staggered dim - 1)')
4 changes: 2 additions & 2 deletions wrfconf/conf/parse_namelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import yaml

default_parser = re.compile('^[a-z0-9 _()\t]*?=(.+?)[;\(\|]?(.*)$', re.DOTALL)
default_parser = re.compile('^[a-z0-9 _()\t]*?=.s*?([0-9\w,<>\'\s]+)[;\(\|]?(.*)$', re.DOTALL)


def is_command(l):
Expand Down Expand Up @@ -48,7 +48,7 @@ def process(self, l):

res = default_parser.search(l, )
if res:
self.default = res.group(1).strip()
self.default = res.group(1).strip().strip(',')
self.description = res.group(2).strip()
self.description = '\n'.join([a.strip() for a in self.description.split('\n')])
pass
Expand Down

0 comments on commit b01ad0b

Please sign in to comment.