Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_add_changelog_section(self):
f = open('test_modify_changelog2')
c = f.read()
f.close()
cl = changelog.Changelog(c)
cl.new_block(package='gnutls14',
version=changelog.Version('1:1.4.1-3'),
distributions='experimental',
urgency='low',
author='James Westby ')
self.assertRaises(changelog.ChangelogCreateError, cl.__str__)
cl.set_date('Sat, 16 Jul 2008 11:11:08 +0200')
cl.add_change('')
cl.add_change(' * Foo did not work, let us try bar')
cl.add_change('')
f = open('test_modify_changelog3')
c = f.read()
f.close()
def test_magic_version_properties(self):
f = open('test_changelog')
c = changelog.Changelog(f)
f.close()
self.assertEqual(c.debian_version, '1')
self.assertEqual(c.full_version, '1:1.4.1-1')
self.assertEqual(c.upstream_version, '1.4.1')
self.assertEqual(c.epoch, '1')
self.assertEqual(str(c.version), c.full_version)
def test_set_version_with_string(self):
f = open('test_modify_changelog1')
c1 = changelog.Changelog(f.read())
f.seek(0)
c2 = changelog.Changelog(f.read())
f.close()
c1.version = '1:2.3.5-2'
c2.version = changelog.Version('1:2.3.5-2')
self.assertEqual(c1.version, c2.version)
self.assertEqual((c1.full_version, c1.epoch, c1.upstream_version,
c1.debian_version),
(c2.full_version, c2.epoch, c2.upstream_version,
c2.debian_version))
def test_unicode_object_input(self):
f = open('test_changelog_unicode')
c_str = f.read()
f.close()
c_unicode = c_str.decode('utf-8')
c = changelog.Changelog(c_unicode)
self.assertEqual(unicode(c), c_unicode)
self.assertEqual(str(c), c_str)
def __init__(self, name, part, directory):
self.name = name
self.part = part
if not self.part:
raise Exception('Part required')
self.directory = directory
self.git_repo = git.Repo(self.directory)
self._bumped = False
self.current_version = self._get_current_version()
self.new_version = self._get_new_version()
self._changelog = changelog.Changelog(os.path.join(self.directory, 'CHANGELOG.md'))
def ast_to_changelog(node):
changelog = None
headings = ast_to_headings(node)
if len(headings) > 0 and headings[0].level == 1:
changelog = Changelog(headings[0].title)
headings = headings[1:]
else:
raise Exception('Changelog does not start with a level 1 heading, including the changelog name.')
if any(map(lambda h: h.level == 1, headings)):
raise Exception('Changelog has multiple level 1 headings.')
release = None
for heading in headings:
if heading.level == 2:
if release:
changelog.releases.append(release)
release = Release(heading.title)
elif heading.level == 3:
def __init__(self, name, part, directory):
self.name = name
self.part = part
if not self.part:
raise Exception('Part required')
self.directory = directory
self.git_repo = git.Repo(self.directory)
self._bumped = False
self.current_version = self._get_current_version()
self.new_version = self._get_new_version()
self._changelog = changelog.Changelog(os.path.join(self.directory, 'CHANGELOG.md'))
def change(self):
self.session.open(Changelog, Version)