-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnew.specs.py
48 lines (38 loc) · 1.31 KB
/
new.specs.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import unittest
import glob
import time
import mistletoe
from JobNinjaRenderer import JobNinjaRenderer
all_test_markdowns = glob.glob("./test-data/*.md")
class NewProcessorTestCase(unittest.TestCase):
def test_correctness(self):
# given
self.maxDiff = None
# when
for filename in all_test_markdowns:
with open(filename) as file:
new_rendered_html = mistletoe.markdown(file.read(), JobNinjaRenderer)
with open(filename.replace(".md", ".correct.html")) as html_file:
old_html = html_file.read()
# then
print("Filename", filename)
self.assertEqual(new_rendered_html.replace("\n", ""), old_html.replace("\n", ""))
@unittest.skip("slow")
def test_speed(self):
# given
files = []
for filename in all_test_markdowns:
with open(filename) as file:
files.append(file.read())
start = time.time()
# when
for i in range(0, 1000):
for file in files:
mistletoe.markdown(file, JobNinjaRenderer)
# then
end = time.time()
duration = end - start
message = "It took {}s".format(duration)
self.assertTrue(duration < 10, message)
if __name__ == '__main__':
unittest.main()