diff --git a/unittests/test_macros.py b/unittests/test_macros.py index fe47db888b518035a0b16bc82cd3f439aa16b60d..fea76fe9b031c8b82964e7ab41b4c26486fbba43 100644 --- a/unittests/test_macros.py +++ b/unittests/test_macros.py @@ -43,6 +43,20 @@ def macro_store_reset(): macro_store.clear() +def _temp_file_load(txt: str): + """ + Create a temporary file with txt and load the crawler + definition using load_definition from Crawler. + """ + definition = None + with NamedTemporaryFile() as f: + f.write(txt.encode()) + f.flush() + c = Crawler() + definition = c.load_definition(f.name) + return definition + + def test_macros(register_macros, macro_store_reset): dat = yaml.load(""" defs: @@ -152,20 +166,6 @@ testnode: !macro assert dat["testnode"]["replaced3"] == "ok" -def temp_file_load(txt: str): - """ - Create a temporary file with txt and load the crawler - definition using load_definition from Crawler. - """ - definition = None - with NamedTemporaryFile() as f: - f.write(txt.encode()) - f.flush() - c = Crawler() - definition = c.load_definition(f.name) - return definition - - def test_load_definition(register_macros, macro_store_reset): txt = """ extroot: @@ -177,10 +177,10 @@ extroot: match: SimulationData """ # Check whether simple cfoods can be loaded: - cfood = temp_file_load(txt) + cfood = _temp_file_load(txt) assert cfood["extroot"]["subtree"]["SimulationData"]["match"] == "SimulationData" - cfood = temp_file_load(""" + cfood = _temp_file_load(""" --- metadata: macros: