def test_single_version_Changelog(): changelog = Changelog('foo') populate_changelog_from_rst(changelog, single_version_rst) expected_versions = ['0.0.1'] versions = [] for version, date, content in changelog.foreach_version(): versions.append(version) assert sorted(expected_versions) == sorted(versions)
def test_single_version_with_header_Changelog(): changelog = Changelog('foo') populate_changelog_from_rst(changelog, single_version_with_header_rst) expected_versions = ['0.0.1'] versions = [] for version, date, content in changelog.foreach_version(): versions.append(version) assert sorted(expected_versions) == sorted(versions)
def main(sysargs=None): parser = argparse.ArgumentParser(description="Tests a REP-0132 %s" % CHANGELOG_FILENAME) parser.add_argument('changelog_file', help="%s file to parse" % CHANGELOG_FILENAME, default='.', nargs='?') args = parser.parse_args(sysargs) if os.path.isdir(args.changelog_file): changelog_file = os.path.join(args.changelog_file, CHANGELOG_FILENAME) if not os.path.exists(changelog_file): print("No {0} file in given directory: '{1}'".format( CHANGELOG_FILENAME, args.changelog_file), file=sys.stderr) return 1 else: changelog_file = args.changelog_file if not os.path.exists(changelog_file): print("{0} file given does not exist: '{1}'".format( CHANGELOG_FILENAME, args.changelog_file), file=sys.stderr) return 1 if os.path.basename(changelog_file) != CHANGELOG_FILENAME: print("WARNING: changelog file name should be %s" % CHANGELOG_FILENAME) logging.basicConfig() catkin_pkg.changelog.log.setLevel(logging.DEBUG) changelog = Changelog() with open(changelog_file, 'r') as f: print(populate_changelog_from_rst(changelog, f.read()))
def test_Changelog(): # Example is from REP-0132 changelog = Changelog('foo') populate_changelog_from_rst(changelog, example_rst) expected_versions = ['0.1.26', '0.1.25', '0.1.0', '0.0.1'] versions = [] content_checks = { '0.1.26': check_0_1_26, '0.1.25': check_0_1_25, '0.1.0': check_0_1_0, '0.0.1': check_0_0_1 } for version, date, content in changelog.foreach_version(): versions.append(version) if version in content_checks: content_checks[version](content) assert sorted(expected_versions) == sorted(versions)