diff --git a/src/catkin_pkg/cli/tag_changelog.py b/src/catkin_pkg/cli/tag_changelog.py index b0573432..e2fbe954 100644 --- a/src/catkin_pkg/cli/tag_changelog.py +++ b/src/catkin_pkg/cli/tag_changelog.py @@ -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') diff --git a/test/test_tag_changelog.py b/test/test_tag_changelog.py new file mode 100644 index 00000000..a5b49c90 --- /dev/null +++ b/test/test_tag_changelog.py @@ -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