diff --git a/swh/web/tests/common/test_utils.py b/swh/web/tests/common/test_utils.py --- a/swh/web/tests/common/test_utils.py +++ b/swh/web/tests/common/test_utils.py @@ -6,6 +6,8 @@ import datetime from urllib.parse import quote +import docutils +from pkg_resources import parse_version import pytest from django.conf.urls import url @@ -122,24 +124,29 @@ "#. It has two items too.\n" ) + if parse_version(docutils.__version__) >= parse_version("0.17"): + (section_open, section_close) = ("section", "section") + else: + (section_open, section_close) = ('div class="section"', "div") + expected_html = ( - '

Section

\n' - "

Some strong text

\n" - '
\n' - "

Subsection

\n" - '\n" - '
    \n' - "
  1. This is a numbered list.

  2. \n" - "
  3. It has two items too.

  4. \n" - "
  5. This is a numbered list.

  6. \n" - "
  7. It has two items too.

  8. \n" - "
\n" - "
\n" - "
" + f'

Section

\n' + f"

Some strong text

\n" + f'<{section_open} id="subsection">\n' + f"

Subsection

\n" + f'\n" + f'
    \n' + f"
  1. This is a numbered list.

  2. \n" + f"
  3. It has two items too.

  4. \n" + f"
  5. This is a numbered list.

  6. \n" + f"
  7. It has two items too.

  8. \n" + f"
\n" + f"\n" + f"
" ) assert utils.rst_to_html(rst) == expected_html