From f9ac621848ccecd3546fb832b1ee4f9aa2e0da6f Mon Sep 17 00:00:00 2001 From: florian <f.spreckelsen@inidscale.com> Date: Tue, 4 Oct 2022 16:25:41 +0200 Subject: [PATCH] MAINT: Move and rename helper function --- unittests/test_macros.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/unittests/test_macros.py b/unittests/test_macros.py index fe47db88..fea76fe9 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: -- GitLab