-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
32 lines (24 loc) · 999 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import MarkdownParser
import unittest
import os
class TestMyMdParser(unittest.TestCase):
def test_parse_heading(self):
self.maxDiff = None
test_id = 29
md_root_path = f"./testfiles/md"
html_root_path = f"./testfiles/html"
MarkdownParser.parse("")
MarkdownParser.parse("# Heading")
MarkdownParser.parse_toc("")
for i in range(1, test_id + 1):
md_path = os.path.join(md_root_path, f"test{i}.md")
html_path = os.path.join(html_root_path, f"test{i}.html")
MarkdownParser.parse_file(md_path)
html = MarkdownParser.parse_file_toc(md_path)
# with open(html_path, "w", encoding="utf-8") as f:
# f.write(html)
with open(html_path, "r", encoding="utf-8") as f:
self.assertEqual(f.read(), html, f"test{i} error")
print("pass")
if __name__ == "__main__":
unittest.main()