Total Complexity | 6 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from pathlib import Path |
||
2 | from unittest import TestCase |
||
3 | |||
4 | from panflute.tools import convert_text |
||
5 | |||
6 | from amsthm import main |
||
7 | |||
8 | DIR = Path(__file__).parent |
||
9 | |||
10 | |||
11 | class TestAmsthm(TestCase): |
||
12 | def setUp(self): |
||
13 | with (DIR / "model-source.md").open("r") as f: |
||
14 | self.text = f.read() |
||
15 | with (DIR / "model-latex.tex").open("r") as f: |
||
16 | self.ref_latex = f.read() |
||
17 | with (DIR / "model-target.md").open("r") as f: |
||
18 | self.ref_md = f.read() |
||
19 | |||
20 | def test_filter_latex(self): |
||
21 | doc = convert_text(self.text, standalone=True) |
||
22 | # force to convert to latex |
||
23 | doc.format = "latex" |
||
24 | main(doc) |
||
25 | res = convert_text( |
||
26 | doc, |
||
27 | input_format="panflute", |
||
28 | output_format="latex", |
||
29 | extra_args=["--top-level-division=chapter", "--toc", "-N"], |
||
30 | ) |
||
31 | assert res.strip() == self.ref_latex.strip() |
||
32 | |||
33 | def test_filter_non_latex(self): |
||
34 | doc = convert_text(self.text, standalone=True) |
||
35 | # force to convert to latex |
||
36 | doc.format = "markdown" |
||
37 | main(doc) |
||
38 | res = convert_text( |
||
39 | doc, |
||
40 | input_format="panflute", |
||
41 | output_format="markdown", |
||
42 | ) |
||
43 | assert res.strip() == self.ref_md.strip() |
||
44 |