| 1 | import json |
| 2 | from pathlib import Path |
| 3 | import runpy |
| 4 | import shutil |
| 5 | from tempfile import TemporaryDirectory |
| 6 | import unittest |
| 7 | |
| 8 | ROOT = Path(__file__).resolve().parent.parent |
| 9 | FIXTURE = ROOT / 'corpus/cross-run-edit' |
| 10 | compare = runpy.run_path(str(ROOT / 'tools/verify-document.py'))['compare'] |
| 11 | |
| 12 | |
| 13 | class CrossRunEditTest(unittest.TestCase): |
| 14 | def test_cold_native_text_styles_and_structure(self): |
| 15 | for case in json.loads((FIXTURE / 'manifest.json').read_text())['cases']: |
| 16 | with self.subTest(case=case['name']), TemporaryDirectory() as temporary: |
| 17 | fixture = FIXTURE / case['name'] |
| 18 | native = Path(temporary) / 'read' |
| 19 | shutil.copytree(fixture / 'cold/read', native) |
| 20 | compare(fixture / 'candidate', native) |
| 21 | compare(fixture / 'cold/notebook', native) |
| 22 | |
| 23 | |
| 24 | if __name__ == '__main__': |
| 25 | unittest.main() |