def _test_file_extraction_and_validation(
        self, dest_dir, file_path, archive_type
    ):
        """Helper function for file extraction and validation."""
        origin = urllib.parse.urljoin(
            "file://",
            urllib.request.pathname2url(os.path.abspath(file_path)),
        )

        hashval_md5 = file_utils.hash_file(file_path, algorithm="md5")

        if archive_type:
            extract = True
        else:
            extract = False

        path = file_utils.get_file(
            "test",
            origin,
            md5_hash=hashval_md5,
            extract=extract,
            cache_subdir=dest_dir,
        )
        if extract:
            fpath = path + "_archive"
        else:
            fpath = path

        self.assertTrue(os.path.exists(path))
        self.assertTrue(file_utils.validate_file(fpath, hashval_md5))
        if extract:
            self.assertTrue(os.path.exists(os.path.join(path, "test.txt")))
Helper function for file extraction and validation.
keras/src/utils/file_utils_test.py