Skip to content

Commit

Permalink
Merge code
Browse files Browse the repository at this point in the history
- Merge conflict-causing code from branch '9.x'. This does not affect
  functionality of the 'dev' branch
  • Loading branch information
frnmst committed Nov 20, 2023
1 parent 9edbafc commit 5c4cb74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 102 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ test:
&& tox run-parallel \
&& deactivate

fuzzer:
$(VENV_CMD) \
&& tox run -e fuzzer \
&& deactivate

pre-commit:
$(VENV_CMD) \
&& pre-commit run --all \
Expand Down Expand Up @@ -119,11 +124,12 @@ upload:
clean:
rm -rf build dist *.egg-info tests/benchmark-results
# Remove all markdown files except the readmes.
find -regex ".*\.[mM][dD]" \
find -regex "\(.*/crash-[a-f0-9]+\|.*\.[mM][dD]\)$$" \
! -name 'README.md' \
! -name 'CONTRIBUTING.md' \
! -name 'SECURITY.md' \
-type f -exec rm -f {} +
! -path './.venv/*' \
! -path './.git/*' -type f -exec rm -f {} +
$(VENV_CMD) \
&& $(MAKE) -C docs clean \
&& deactivate
Expand Down
100 changes: 0 additions & 100 deletions md_toc/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4424,106 +4424,6 @@ def test_is_closing_code_fence(self):
api.is_closing_code_fence(TILDE3 + T1, TILDE3, 'cmark'), )
self.assertFalse(api.is_closing_code_fence(TILDE3 + T4 + S4, TILDE3), )

@unittest.skip('empty test')
def test_init_indentation_status_list(self):
r"""Test building of the indentation data structure.
There is no need to test this since it is a trivial function.
"""

def _test_helper_toc_renders_as_coherent_list(
self,
header_type_curr,
header_type_first,
indentation_list,
expected_indentation_list,
expected_result,
):
result = api.toc_renders_as_coherent_list(
header_type_curr,
header_type_first,
indentation_list,
)
self.assertEqual(result, expected_result)
self.assertEqual(indentation_list, expected_indentation_list)

def test_toc_renders_as_coherent_list(self):
r"""Test if the TOC renders as a list the user intended."""
# github and redcarpet.

# 1. header_type_first = 1; header_type_curr = 1.
expected_indentation_list = [True, False, False, False, False, False]
self._test_helper_toc_renders_as_coherent_list(
BASE_CASE_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR,
BASE_CASE_CMARK_RENDERS_AS_LIST_HEADER_TYPE_FIRST,
api.init_indentation_status_list('github'),
expected_indentation_list,
True,
)

# 2. header_type_first = 1; header_type_curr = generic > 1.
indentation_list = api.init_indentation_status_list('github')
for i in range(0, GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR - 1):
indentation_list[i] = True
expected_indentation_list = [True, True, True, True, False, False]
self._test_helper_toc_renders_as_coherent_list(
GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR,
BASE_CASE_CMARK_RENDERS_AS_LIST_HEADER_TYPE_FIRST,
indentation_list,
expected_indentation_list,
True,
)

# 3. header_type_first = generic > 1; header_type_curr = 1.
indentation_list = api.init_indentation_status_list('github')
expected_indentation_list = [True, False, False, False, False, False]
self._test_helper_toc_renders_as_coherent_list(
BASE_CASE_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR,
GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_FIRST,
indentation_list,
expected_indentation_list,
False,
)

# 4. header_type_first = generic > 1; header_type_curr = generic > 1; header_type_curr > header_type_first.
indentation_list = api.init_indentation_status_list('github')
indentation_list[GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_FIRST -
1] = True
expected_indentation_list = [False, False, False, True, True, False]
self._test_helper_toc_renders_as_coherent_list(
GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR_BIS,
GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_FIRST,
indentation_list,
expected_indentation_list,
True,
)

# 4. header_type_first = generic > 1; header_type_curr = generic > 1; header_type_curr == header_type_first.
indentation_list = api.init_indentation_status_list('github')
indentation_list[GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR -
1] = True
expected_indentation_list = [False, False, False, True, False, False]
self._test_helper_toc_renders_as_coherent_list(
GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR,
GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR,
indentation_list,
expected_indentation_list,
True,
)

# 5. header_type_first = generic > 1; header_type_curr = generic > 1; header_type_curr < header_type_first.
indentation_list = api.init_indentation_status_list('github')
indentation_list[GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR_BIS -
1] = True
expected_indentation_list = [False, False, False, True, False, False]
self._test_helper_toc_renders_as_coherent_list(
GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_FIRST,
GENERIC_CMARK_RENDERS_AS_LIST_HEADER_TYPE_CURR_BIS,
indentation_list,
expected_indentation_list,
False,
)


if __name__ == '__main__':
unittest.main()

0 comments on commit 5c4cb74

Please sign in to comment.