From b29cfbc3cef4e10f5f5b3ded03bdd6f388800dba Mon Sep 17 00:00:00 2001 From: IanCa Date: Fri, 14 Jun 2024 13:55:37 -0500 Subject: [PATCH] Fix script_util tests --- tests/scripts/test_script_util.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/scripts/test_script_util.py b/tests/scripts/test_script_util.py index f87feccc..55989be1 100644 --- a/tests/scripts/test_script_util.py +++ b/tests/scripts/test_script_util.py @@ -31,6 +31,38 @@ def test_none_extension(self): class TestSortBaseSchemas(unittest.TestCase): + TEST_DIR = 'test_directory' + + @classmethod + def setUpClass(cls): + if not os.path.exists(cls.TEST_DIR): + os.makedirs(cls.TEST_DIR) + os.chdir(cls.TEST_DIR) + cls.create_stub_files() + + @classmethod + def tearDownClass(cls): + os.chdir('..') + shutil.rmtree(cls.TEST_DIR) + + @classmethod + def create_stub_files(cls): + filenames = [ + "test_schema.mediawiki", + os.path.normpath("hedtsv/test_schema/test_schema_Tag.tsv"), + "other_schema.xml", + os.path.normpath("hedtsv/wrong_folder/wrong_name_Tag.tsv"), + os.path.normpath("prerelease/hedtsv/test_schema/test_schema_Tag.tsv"), + os.path.normpath("not_hedtsv/test_schema/test_schema_Tag.tsv") + ] + for filename in filenames: + filepath = os.path.normpath(filename) + directory = os.path.dirname(filepath) + if directory: + os.makedirs(directory, exist_ok=True) + with open(filepath, 'w') as f: + f.write('') # Create an empty file + def test_mixed_file_types(self): filenames = [ "test_schema.mediawiki",