-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_minsert.py
37 lines (27 loc) · 1.06 KB
/
test_minsert.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
#!/usr/bin/env python
# pylint: skip-file
from minsert.minsert import MarkdownFile, is_comment, is_ender, is_starter
def test_is_comment():
assert is_comment("<!-- -->")
assert is_comment("<!-- hello how are you -->")
assert is_comment("<!-- -->")
assert not is_comment("< !-- -->")
assert not is_comment("<!-- -- >")
def test_is_starter():
assert not is_starter("<!-- start -->")
assert is_starter("<!-- start block -->") == "block"
assert not is_starter("Normal Sentence")
def test_is_ender():
assert is_ender("<!-- end -->")
assert is_ender("<!-- end blah blah-->")
assert is_ender("<!-- blah end blah-->")
assert not is_ender("end")
assert not is_ender("<!-- blend -->")
def test_minsert():
with open("test.md", "w") as file:
file.write("Hello\n<!-- start block-->\n<!-- end -->\nOk bye")
mfile = MarkdownFile("test.md")
mfile.insert({"block": "what"})
with open("test.md") as file:
content = file.read()
assert content == "Hello\n<!-- start block-->\nwhat\n<!-- end -->\nOk bye"