From 2414a1def4af92257638d8c2b28bdc4ee4cbe627 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 8 Oct 2018 11:12:32 +0300 Subject: Add testsuite --- .gitignore | 2 +- MANIFEST.in | 3 +++ releaselog/input.py | 2 +- setup.py | 12 +++++----- tests/__init__.py | 9 ++++++++ tests/rlogtester.py | 7 ++++++ tests/test_cpan.py | 37 +++++++++++++++++++++++++++++++ tests/test_gnu.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test_python.py | 34 ++++++++++++++++++++++++++++ 9 files changed, 160 insertions(+), 8 deletions(-) create mode 100644 MANIFEST.in create mode 100644 tests/__init__.py create mode 100644 tests/rlogtester.py create mode 100644 tests/test_cpan.py create mode 100644 tests/test_gnu.py create mode 100644 tests/test_python.py diff --git a/.gitignore b/.gitignore index 5f2763b..4dea9de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *~ *.pyc -.emacs.desktop +.emacs.* build/ dist/ tmp/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..268ee5b --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +exclude .gitignore +include COPYING.txt +include CHANGES.txt diff --git a/releaselog/input.py b/releaselog/input.py index ebf8ab6..138ba16 100644 --- a/releaselog/input.py +++ b/releaselog/input.py @@ -30,7 +30,7 @@ class ReleaseLogFile(ReleaseLog): class ReleaseLogURL(ReleaseLog): - """Read history log entries from a URL file. + """Read history log entries from a URL. Usage: hist = ReleaseLogURL(fmt, url [, args...]) diff --git a/setup.py b/setup.py index 9844af3..37a2b41 100644 --- a/setup.py +++ b/setup.py @@ -18,11 +18,11 @@ from setuptools import setup, find_packages from codecs import open -#with open("README.rst", "r") as fh: -# long_description = fh.read() +with open("README.rst", "r") as fh: + long_description = fh.read() setup(name='releaselog', - version='0.2', + version='0.3', author='Sergey Poznyakoff', author_email='gray@gnu.org', url='http://git.gnu.org.ua/cgit/gsc/releaselog.git/', @@ -31,10 +31,10 @@ setup(name='releaselog', scripts=['bin/releaselog'], license='GPL License', description='Release log parser.', -# long_description=long_description, -# long_description_content_type="text/x-rst", + long_description=long_description, + long_description_content_type="text/x-rst", platforms=['any'], - # test_suite='tests', + test_suite='tests', classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..87f4c50 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,9 @@ +import unittest +import sys +from os.path import dirname, abspath + +sys.path.insert(0,dirname(abspath(__file__))) + +def test_suite(): + loader = unittest.TestLoader() + return loader.loadTestFromModule() diff --git a/tests/rlogtester.py b/tests/rlogtester.py new file mode 100644 index 0000000..7e4b374 --- /dev/null +++ b/tests/rlogtester.py @@ -0,0 +1,7 @@ +import unittest +from releaselog import ReleaseLog + +class ReleaseLogTestCase(unittest.TestCase): + def setUp(self): + self.rlog = ReleaseLog(self.type, self.input.split("\n"), + **self.kwargs) diff --git a/tests/test_cpan.py b/tests/test_cpan.py new file mode 100644 index 0000000..b707c8d --- /dev/null +++ b/tests/test_cpan.py @@ -0,0 +1,37 @@ +from rlogtester import ReleaseLogTestCase + +class CPANReleseLogTestCase(ReleaseLogTestCase): + type = 'CPAN' + kwargs = { } + input = """ +Revision history for Perl extension Config::HAProxy. + +1.02 Mon Jul 16 07:38:31 2018 + - remove the leftover use of autodie + +1.01 Thu Jul 12 09:04:28 2018 + - set minimal required Perl version + - drop dependency on autodie + +1.00 Sun Jul 8 19:57:57 2018 + - original revision + +0.05 2018-05-20 + - experimental version +""" + def test_count(self): + self.assertEqual(len(self.rlog), 4, "wrong count") + + def test_recent(self): + elt = self.rlog[0] + self.assertEqual(elt.version, "1.02") + + def test_index(self): + elt = self.rlog[2] + self.assertEqual(elt.version, "1.00") + +if __name__ == '__main__': + unittest.main() + + + diff --git a/tests/test_gnu.py b/tests/test_gnu.py new file mode 100644 index 0000000..090949c --- /dev/null +++ b/tests/test_gnu.py @@ -0,0 +1,62 @@ +from rlogtester import ReleaseLogTestCase + +class GNUReleseLogTestCase(ReleaseLogTestCase): + type = 'GNU' + kwargs = { } + input = """ +GNU mailutils NEWS -- history of user-visible changes. 2018-08-29 +Copyright (C) 2002-2018 Free Software Foundation, Inc. +See the end of file for copying conditions. + +Please send mailutils bug reports to . + +Version 3.5.90 (Git) + +* Bugfixes + +Version 3.5, 2018-08-29 + +* Support for Guile version 2.2.0 and later + +Support for prior versions has been withdrawn. + +* New scheme functions + +** mu-encoder-port port name . args + +Version 3.4 - 2017-11-02 + +* Fix AM_MAILUTILS macro + +The macro incorrectly compared three-part version number with a +two-part argument. + +Version 3.3 - Sergey Poznyakoff, 2017-10-18 + +* TLS configuration + +Some changes to the TLS configuration + +Version 3.2 - 2017-03-11 + +* configuration syntax + +Statements that allow for variable substitution also allow for command +expansion. Commands are invoked the same way as in shell. +""" + + def test_count(self): + self.assertEqual(len(self.rlog), 4, "wrong count") + + def test_recent(self): + elt = self.rlog[0] + self.assertEqual(elt.version, "3.5") + + def test_index(self): + elt = self.rlog[2] + self.assertEqual(elt.version, "3.3") + +if __name__ == '__main__': + unittest.main() + + diff --git a/tests/test_python.py b/tests/test_python.py new file mode 100644 index 0000000..904cc82 --- /dev/null +++ b/tests/test_python.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +from rlogtester import ReleaseLogTestCase + +class PythonReleseLogTestCase(ReleaseLogTestCase): + type = 'python' + kwargs = { } + input = """ +v1.3, 2018-09-01 -- Don't throw exception on invalid tokens. + Fix python 3 compatibility +v1.2, 2018-08-27 -- Fix handling of unrecognized closing tags. +v1.1, 2018-08-24 -- Initialize token_class dynamically. +v1.0, 2018-08-19 -- Initial release. + +""" + + def test_count(self): + self.assertEqual(len(self.rlog), 4, "wrong count") + + def test_recent(self): + elt = self.rlog[0] + self.assertEqual(elt.version, "1.3") + + def test_index(self): + elt = self.rlog[2] + self.assertEqual(elt.version, "1.1") + + def test_descr(self): + self.assertEqual('\n'.join(self.rlog[0].descr),"""Don't throw exception on invalid tokens. + Fix python 3 compatibility""") + self.assertEqual('\n'.join(self.rlog[2].descr),"Initialize token_class dynamically.") + +if __name__ == '__main__': + unittest.main() + -- cgit v1.2.1