File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # pylint: skip-file
4+
5+ from minsert .minsert import MarkdownFile , is_comment , is_ender , is_starter
6+
7+
8+ def test_is_comment ():
9+ assert is_comment ("<!-- -->" )
10+ assert is_comment ("<!-- hello how are you -->" )
11+ assert is_comment ("<!-- -->" )
12+ assert not is_comment ("< !-- -->" )
13+ assert not is_comment ("<!-- -- >" )
14+
15+
16+ def test_is_starter ():
17+ assert not is_starter ("<!-- start -->" )
18+ assert is_starter ("<!-- start block -->" ) == "block"
19+ assert not is_starter ("Normal Sentence" )
20+
21+
22+ def test_is_ender ():
23+ assert is_ender ("<!-- end -->" )
24+ assert is_ender ("<!-- end blah blah-->" )
25+ assert is_ender ("<!-- blah end blah-->" )
26+ assert not is_ender ("end" )
27+ assert not is_ender ("<!-- blend -->" )
28+
29+
30+ def test_minsert ():
31+ with open ("test.md" , "w" ) as file :
32+ file .write ("Hello\n <!-- start block-->\n <!-- end -->\n Ok bye" )
33+ mfile = MarkdownFile ("test.md" )
34+ mfile .insert ({"block" : "what" })
35+ with open ("test.md" ) as file :
36+ content = file .read ()
37+ assert content == "Hello\n <!-- start block-->\n what\n <!-- end -->\n Ok bye"
You can’t perform that action at this time.
0 commit comments