Spaces:
Running on Zero
Running on Zero
| import tempfile | |
| import unittest | |
| from pathlib import Path | |
| from zsgdp.config import load_config | |
| from zsgdp.parsers.text_parser import TextParser | |
| from zsgdp.profiling import profile_document | |
| class TextParserTests(unittest.TestCase): | |
| def test_text_parser_extracts_elements_and_tables(self): | |
| with tempfile.TemporaryDirectory() as tmp: | |
| path = Path(tmp) / "sample.md" | |
| path.write_text("# Report\n\nParagraph.\n\n| A | B |\n| --- | --- |\n| 1 | 2 |\n", encoding="utf-8") | |
| profile = profile_document(path) | |
| candidate = TextParser().parse(path, profile, load_config()) | |
| self.assertEqual(candidate.parser_name, "text") | |
| self.assertGreaterEqual(len(candidate.elements), 2) | |
| self.assertEqual(len(candidate.tables), 1) | |
| if __name__ == "__main__": | |
| unittest.main() | |