From 9aa8224faa79ac1472a70ae6fe6594022c22a2e6 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 22 Feb 2013 10:15:08 -0500 Subject: Change `set.append` -> `set.add` in `headerid.unique` Fixes #195. This was getting missed because the HeadrerId extension's reset method was resetting the IDs to a list. However, some third party extensions may want to call the unique function and it should work as documented. Interestingly, the TOC extension was using it and passing in a list as well. All fixed now. Also added a test of the `unique` function directly so we shouldn't repeat this in the future. --- tests/test_extensions.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/test_extensions.py b/tests/test_extensions.py index fa9a801..d9d77b8 100644 --- a/tests/test_extensions.py +++ b/tests/test_extensions.py @@ -199,6 +199,13 @@ class TestHeaderId(unittest.TestCase): self.assertEqual(self.md.convert(text), '

Some Header

') + def testUniqueFunc(self): + """ Test 'unique' function. """ + from markdown.extensions.headerid import unique + ids = set(['foo']) + self.assertEqual(unique('foo', ids), 'foo_1') + self.assertEqual(ids, set(['foo', 'foo_1'])) + def testUniqueIds(self): """ Test Unique IDs. """ -- cgit v1.2.3