From aefff0557126540c1536224e255016e4bb80f4d7 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Tue, 10 Oct 2023 22:04:32 -0400 Subject: [PATCH] Testing: cogroup patch/update tests 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. --- tests/test_f90nml.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_f90nml.py b/tests/test_f90nml.py index cf3621c..ef0ee7d 100644 --- a/tests/test_f90nml.py +++ b/tests/test_f90nml.py @@ -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)