MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / test_macro_replace

Method test_macro_replace

tests/bundle/test_config_parser.py:221–229  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

219 self.assertEqual(str(item), str({"key": 1, "value1": 2, "value2": 2, "value3": [3, 4, 4, 105]}))
220
221 def test_macro_replace(self):
222 with tempfile.TemporaryDirectory() as tempdir:
223 another_file = os.path.join(tempdir, "another.json")
224 ConfigParser.export_config_file(config={"E": 4}, filepath=another_file)
225 # test macro with id, relative id, and macro in another file
226 config = {"A": {"B": 1, "C": 2}, "D": [3, "%A#B", "%#0", f"%{another_file}#E"]}
227 parser = ConfigParser(config=config)
228 parser.resolve_macro_and_relative_ids()
229 self.assertEqual(str(parser.get()), str({"A": {"B": 1, "C": 2}, "D": [3, 1, 3, 4]}))
230
231 @parameterized.expand([TEST_CASE_4])
232 def test_allow_missing_reference(self, config):

Callers

nothing calls this directly

Calls 4

getMethod · 0.95
ConfigParserClass · 0.90
export_config_fileMethod · 0.80

Tested by

no test coverage detected