On Fri, 2020-05-15 at 10:59 +0200, Martin Liška wrote:
> Hi.
>
> Since we moved to git world and we're in the preparation for
> ChangeLog messages
> being in git commit messages, I think it's the right time to also
> simplify mklog
> script.
>
> I'm sending a new version (which should eventually replace
> contrib/mklog and contrib/mklog.pl).
> Changes made in the version:
>
> - the script uses unifdiff - it rapidly simplifies parsing of the '+-
> !' lines that is done
> in contrib/mklog
> - no author nor date stamp is used - that all can be get from git
> - --inline option is not supported - I don't see a use-case for it
> now
> - the new script has a unit tests (just few of them for now)
>
> I compares results in between the old Python script for last 80
> commits and it's very close,
> in some cases it does even better.
>
> I'm planning to maintain and improve the script for the future.
>
> Thoughts?
> Martin
> +class TestMklog(unittest.TestCase):
> + def test_macro_definition(self):
> + changelog = generate_changelog(PATCH1)
> + assert changelog == EXPECTED1
> +
> + def test_changed_argument(self):
> + changelog = generate_changelog(PATCH2)
> + assert changelog == EXPECTED2
> +
> + def test_enum_and_struct(self):
> + changelog = generate_changelog(PATCH3)
> + assert changelog == EXPECTED3
> +
> + def test_no_function(self):
> + changelog = generate_changelog(PATCH3, True)
> + assert changelog == EXPECTED3B
Use self.assertEqual(a, b) rather than assert a == b, so that if it
fails you get a multiline diff:
e.g.:
import unittest
class TestMklog(unittest.TestCase):
def test_macro_definition(self):
self.assertEqual('''
first
second
third''', '''
first
SECOND
third''')
unittest.main()
has this output:
F
======================================================================
FAIL: test_macro_definition (__main__.TestMklog)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/foo.py", line 11, in test_macro_definition
third''')
AssertionError: '\nfirst\nsecond\nthird' != '\nfirst\nSECOND\nthird'
first
- second
+ SECOND
third
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)
which is much easier to debug than the output from assert a == b, which
is just:
F
======================================================================
FAIL: test_macro_definition (__main__.TestMklog)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/foo.py", line 11, in test_macro_definition
third''')
AssertionError
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)