From daaf21ca8ddd2fb52c67327239792265d1313b30 Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sun, 25 Apr 2021 19:54:00 -0700 Subject: [PATCH] Cleanup --- tests/test_changelog.py | 22 +++++++++++++++------- yaclog/__init__.py | 2 +- yaclog/changelog.py | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/test_changelog.py b/tests/test_changelog.py index bd3b4ed..2e5d320 100644 --- a/tests/test_changelog.py +++ b/tests/test_changelog.py @@ -1,9 +1,8 @@ -import unittest -import yaclog.changelog import os.path -import datetime -import textwrap import tempfile +import unittest + +import yaclog.changelog from tests.common import log, log_segments, log_text @@ -17,16 +16,20 @@ class TestParser(unittest.TestCase): fd.write(log_text) cls.log = yaclog.read(cls.path) - def test_header(self): - self.assertEqual(log.header, self.log.header) - def test_path(self): + """Test the log's path""" self.assertEqual(self.path, self.log.path) + def test_header(self): + """Test the header information at the top of the file""" + self.assertEqual(log.header, self.log.header) + def test_links(self): + """Test the links at the end of the file""" self.assertEqual({'fullversion': 'http://endless.horse', **log.links}, self.log.links) def test_versions(self): + """Test the version headers""" for i in range(len(self.log.versions)): self.assertEqual(log.versions[i].name, self.log.versions[i].name) self.assertEqual(log.versions[i].link, self.log.versions[i].link) @@ -34,6 +37,7 @@ class TestParser(unittest.TestCase): self.assertEqual(log.versions[i].tags, self.log.versions[i].tags) def test_entries(self): + """Test the change entries""" self.assertEqual(log.versions[0].sections, self.log.versions[0].sections) @@ -49,19 +53,23 @@ class TestWriter(unittest.TestCase): cls.log_segments = [line for line in cls.log_text.split('\n\n') if line] def test_header(self): + """Test the header information at the top of the file""" self.assertEqual(log_segments[0:2], self.log_segments[0:2]) def test_links(self): + """Test the links at the end of the file""" self.assertEqual( {'[fullversion]: http://endless.horse', '[id]: http://www.koalastothemax.com'}, set(self.log_segments[16:18])) def test_versions(self): + """Test the version headers""" self.assertEqual('## [Tests]', self.log_segments[2]) self.assertEqual('## [FullVersion] - 1969-07-20 [TAG1] [TAG2]', self.log_segments[14]) self.assertEqual('## Long Version Name', self.log_segments[15]) def test_entries(self): + """Test the change entries""" self.assertEqual(log_segments[3], self.log_segments[3]) self.assertEqual('### Bullet Points', self.log_segments[4]) self.assertEqual(log_segments[5], self.log_segments[5]) diff --git a/yaclog/__init__.py b/yaclog/__init__.py index cac66ac..81de5ea 100644 --- a/yaclog/__init__.py +++ b/yaclog/__init__.py @@ -2,7 +2,7 @@ import os from yaclog.changelog import Changelog -def read(path: os.PathLike): +def read(path): """ Create a new Changelog object from the given path :param path: a path to a markdown changelog file diff --git a/yaclog/changelog.py b/yaclog/changelog.py index 521add8..d7ba2bc 100644 --- a/yaclog/changelog.py +++ b/yaclog/changelog.py @@ -114,7 +114,7 @@ class VersionEntry: class Changelog: - def __init__(self, path: os.PathLike = None): + def __init__(self, path=None): self.path: os.PathLike = path self.header: str = '' self.versions: List[VersionEntry] = []