Browse Source

Fixed a unit test and a docstring.

master
Franco Masotti 3 years ago
parent
commit
6252610fb1
  1. 3
      md_toc/api.py
  2. 25
      tests/tests.py

3
md_toc/api.py

@ -249,8 +249,7 @@ def build_list_marker_log(parser='github', list_marker='.'):
:returns: list_marker_log
:rtype: list
:raises: one of the built-in exceptions.
:note: Please note that this function makes sense only for
ordered lists.
:note: This function makes sense for ordered lists only.
"""
assert isinstance(parser, str)
assert isinstance(list_marker, str)

25
tests/tests.py

@ -54,6 +54,7 @@ H7 = 7 * '#'
# Lists.
LIST_INDENTATION = 4
UNORDERED_LIST_SYMBOL = '-'
ORDERED_LIST_SYMBOL = '.'
# Header types.
GENERIC_HEADER_TYPE_PREV = 2
@ -136,7 +137,7 @@ class TestApi(unittest.TestCase):
"""
# github.
# Unordered TOC. In this case there is no need to do specific tests
# on the returned list marker log.
# on the modified list marker log.
# First TOC line.
self.assertEqual(
@ -300,13 +301,13 @@ class TestApi(unittest.TestCase):
r"""Test TOC line building for different types of inputs.
"""
# github and redcarpet.
# FIXME.
header = {
'type': GENERIC_HEADER_TYPE_CURR,
'text_original': LINE,
'text_anchor_link': LINE
}
# Unordered.
self.assertEqual(
api.build_toc_line_without_indentation(
header, ordered=False, no_links=True, parser='github'),
@ -317,6 +318,24 @@ class TestApi(unittest.TestCase):
header, ordered=False, no_links=False, parser='github'),
UNORDERED_LIST_SYMBOL + S1 + '[' + LINE + ']' + '(#' + LINE + ')')
# Ordered.
self.assertEqual(
api.build_toc_line_without_indentation(
header,
ordered=True,
no_links=True,
list_marker=ORDERED_LIST_SYMBOL,
parser='github'), '1' + ORDERED_LIST_SYMBOL + S1 + LINE)
self.assertEqual(
api.build_toc_line_without_indentation(
header,
ordered=True,
no_links=False,
list_marker=ORDERED_LIST_SYMBOL,
parser='github'), '1' + ORDERED_LIST_SYMBOL + S1 + '[' + LINE +
']' + '(#' + LINE + ')')
def test_build_toc_line(self):
r"""Test that the TOC line is built correctly.

Loading…
Cancel
Save