import random import string from typing import Any, Dict, List from unittest.mock import MagicMock, patch import pytest # Data gen @pytest.fixture def generate_text_data(): """Generates various types of text data.""" def _gen(type="clean", length=100): if type == "clean": return "".join(random.choices(string.ascii_letters + " ", k=length)) elif type == "html": tags = ["
", "

", "", "", "", ""] content = "".join(random.choices(string.ascii_letters + " ", k=length)) return f"{random.choice(tags)}{content}{random.choice(tags).replace('<', ' 0.5: dup["value"] = source["value"] + 0.001 final_dataset.append(dup) random.shuffle(final_dataset) return final_dataset return _gen