forked from bjonnh/PyOrgMode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_parser.py
36 lines (28 loc) · 1020 Bytes
/
test_parser.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
import PyOrgMode
import tempfile
import unittest
class TestParser(unittest.TestCase):
"""Test the org file parser with a simple org structure"""
def setUp(self):
"""Parse the org structure from a temporary file"""
orgfile = tempfile.NamedTemporaryFile()
orgfile.write('\n'.join((
'* one',
'* two',
'** two point one',
'* three',
'')).encode('UTF-8'))
orgfile.flush()
self.tree = PyOrgMode.OrgDataStructure()
try:
self.tree.load_from_file(orgfile.name)
finally:
orgfile.close()
def test_has_three_top_level_headings(self):
"""The example has three top-level headings"""
self.assertEqual(len(self.tree.root.content), 3)
def test_second_item_has_a_subheading(self):
"""The second top-level heading has one subheading"""
self.assertEqual(len(self.tree.root.content[1].content), 1)
if __name__ == '__main__':
unittest.main()