jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/505225 )
Change subject: textlib: add tests for sections headers with multiple levels ......................................................................
textlib: add tests for sections headers with multiple levels
Change-Id: I25218cc42c40951f7bfca2fa57f2253cb33e3ca3 --- M tests/textlib_tests.py 1 file changed, 29 insertions(+), 0 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index 187f2b5..990e937 100644 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -1739,6 +1739,35 @@ ('text\n\n', [('==title==', '\ncontent\n')], '[[Category:A]]\n') )
+ def test_with_h1_and_h2_sections(self): + """Test for text having h1 and h2 sections.""" + self.assertEqual( + extract_sections( + 'text\n\n' + '=first level=\n' + 'foo\n' + '==title==\n' + 'bar', + self.site), + ('text\n\n', + [('=first level=', '\nfoo\n'), ('==title==', '\nbar')], + '') + ) + + def test_with_h4_and_h2_sections(self): + """Test for text having h4 and h2 sections.""" + self.assertEqual( + extract_sections( + 'text\n\n' + '====title====\n' + '==title 2==\n' + 'content', + self.site), + ('text\n\n', + [('====title====', '\n'), ('==title 2==', '\ncontent')], + '') + ) +
if __name__ == '__main__': # pragma: no cover try:
pywikibot-commits@lists.wikimedia.org