Skip to content

Commit

Permalink
Testing: cogroup patch/update tests
Browse files Browse the repository at this point in the history
Added tests for cogroup patch and update methods.  As with other cogroup
tests, the equivalent operations are still not well-developed, so the
output tests need some improvement in the future.
  • Loading branch information
marshallward committed Oct 11, 2023
1 parent 5b85248 commit aefff05
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_f90nml.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,26 @@ def test_cogroup_set_from_cogrp(self):
test_nml['CASE_CHECK_nml'] = cogrp_nml['CASE_CHECK_nml']
# NOTE: Cogroup equivalence still broken, this just checks usage.

def test_cogroup_patch(self):
cogrp_nml = f90nml.read('cogroup.nml')
cg_patch = {'cogroup_nml': {'x': 3, '_index': 1}}
cogrp_nml.patch(cg_patch)
# NOTE: Cogroup equivalence still broken, this is a weaker test.
self.assertEqual({'x': 3}, cogrp_nml['cogroup_nml'][1])

def test_cogroup_update(self):
cogrp_nml = f90nml.read('cogroup.nml')
cg_patch = {'cogroup_nml': {'x': 3}}
cogrp_nml.patch(cg_patch)
# NOTE: Cogroup equivalence still broken, this is a weaker test.
self.assertEqual({'x': 3}, cogrp_nml['cogroup_nml'][1])

def test_cogroup_update_error(self):
cogrp_nml = f90nml.read('cogroup.nml')
cg_patch = [1, 2, 3]
self.assertRaises(NotImplementedError,
cogrp_nml['cogroup_nml'].update, cg_patch)

def test_key_repeat(self):
test_nml = f90nml.read('key_repeat.nml')
self.assertEqual(test_nml, self.key_repeat_nml)
Expand Down

0 comments on commit aefff05

Please sign in to comment.