Skip to content

Commit 984fddc

Browse files
committed
add unit test for parser
1 parent a0004eb commit 984fddc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_integration.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from pathlib import Path
55
import pickle
6+
from re import L
67
import sys
78
from tempfile import TemporaryDirectory
89
from typing import Any, Iterable, List, Optional, Set, Tuple, Union
@@ -1561,5 +1562,33 @@ def test_pickle(self):
15611562
self.assertEqual(loaded_args.as_dict(), args.as_dict())
15621563

15631564

1565+
class TestParserDescription(TestCase):
1566+
def test_root_parser_description(self):
1567+
class RootParser(Tap):
1568+
"""<Root Parser>"""
1569+
field: str = '1'
1570+
1571+
root_parser = RootParser()
1572+
help_info = root_parser.format_help()
1573+
self.assertIn('<Root Parser>', help_info)
1574+
1575+
def test_sub_parser_description(self):
1576+
1577+
class SubParser(Tap):
1578+
"""<Sub Parser>"""
1579+
sub_field: str = '2'
1580+
1581+
class RootParser(Tap):
1582+
"""<Root Parser>"""
1583+
field: str = '1'
1584+
1585+
def configure(self):
1586+
self.add_subparsers(help='All sub parser')
1587+
self.add_subparser('sub', SubParser)
1588+
1589+
help_desc = RootParser().format_help()
1590+
self.assertIn('<Sub Parser>', help_desc)
1591+
self.assertIn('<Root Parser>', help_desc)
1592+
15641593
if __name__ == '__main__':
15651594
unittest.main()

0 commit comments

Comments
 (0)