Skip to content

Commit

Permalink
Fix AttributeError with docutils >= 0.18 (#352)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott K Logan <[email protected]>
  • Loading branch information
onjen and cottsay authored Jan 9, 2025
1 parent 03bc290 commit eec17e7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/catkin_pkg/cli/tag_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_forthcoming_label(rst):
if len(section.children) > 0 and isinstance(section.children[0], docutils.nodes.title):
title = section.children[0]
if title and len(title.children) > 0 and isinstance(title.children[0], docutils.nodes.Text):
title_text = title.children[0].rawsource
title_text = title.children[0]
if FORTHCOMING_LABEL.lower() in title_text.lower():
if forthcoming_label:
raise RuntimeError('Found multiple forthcoming sections')
Expand Down
43 changes: 43 additions & 0 deletions test/test_tag_changelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding=utf-8

from catkin_pkg.cli.tag_changelog import get_forthcoming_label
from catkin_pkg.cli.tag_changelog import rename_section

single_forthcoming_rst = """\
^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package foo
^^^^^^^^^^^^^^^^^^^^^^^^^
Forthcoming
-----------
* Initial release
* Initial bugs
* Contributors: Sömeöne with UTF-8 in their name
"""

single_version_rst = """\
^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package foo
^^^^^^^^^^^^^^^^^^^^^^^^^
0.0.1 (2012-01-31)
------------------
* Initial release
* Initial bugs
* Contributors: Sömeöne with UTF-8 in their name
"""


def test_get_forthcoming_label():
assert get_forthcoming_label(single_version_rst) is None
assert get_forthcoming_label(single_forthcoming_rst) == 'Forthcoming'


def test_rename_section():
res = rename_section(
single_forthcoming_rst,
'Forthcoming',
'0.0.1 (2012-01-31)')
assert res == single_version_rst

0 comments on commit eec17e7

Please sign in to comment.