import tempfile import os from benchmark.extraction import extract_text_from_file def test_extract_text_txt(): with tempfile.NamedTemporaryFile(suffix=".txt", delete=False, mode="w", encoding="utf-8") as f: f.write("Extracted text sample content.") path = f.name try: text = extract_text_from_file(path) assert text == "Extracted text sample content." finally: os.remove(path) def test_extract_text_csv(): with tempfile.NamedTemporaryFile(suffix=".csv", delete=False, mode="w", encoding="utf-8", newline="") as f: f.write("Header1,Header2\nValue1,Value2") path = f.name try: text = extract_text_from_file(path) assert "Header1" in text assert "Value1" in text finally: os.remove(path)