forked from idank/explainshell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-manpage.py
More file actions
41 lines (31 loc) · 1.17 KB
/
test-manpage.py
File metadata and controls
41 lines (31 loc) · 1.17 KB
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
import unittest, os, subprocess
from explainshell import manpage, store
class test_manpage(unittest.TestCase):
def test_first_paragraph_no_section(self):
m = 'foo\nbar'
l = list(manpage._parsetext(m.splitlines()))
self.assertEqual(l, [store.paragraph(0, 'foo\nbar', None, False)])
def test_sections(self):
m = '''<b>SECTION</b>
a
b
c
<b>SECTION2</b>
a
<b>WITH SPACES</b>
a
<b>EMPTY SECTION SHOULD BE IGNORED</b>
<b>SECTION3</b>
tNOTASECTION'''
parsed = list(manpage._parsetext(m.splitlines()))
self.assertTrue(len(parsed) == 5)
self.assertEqual(parsed, [store.paragraph(0, 'a\nb', 'SECTION', False),
store.paragraph(1, 'c', 'SECTION', False),
store.paragraph(2, 'a', 'SECTION2', False),
store.paragraph(3, 'a', 'WITH SPACES', False),
store.paragraph(4, 'tNOTASECTION', 'SECTION3', False)])
def test_no_synopsis(self):
m = manpage.manpage('foo')
m._text = 'a b c d e f g h i j k l'.replace(' ', '\n')
m.parse()
self.assertEqual(m.aliases, [('foo', 10)])