jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/405539 )
Change subject: [bugfix][TEST] cc: Get cleanUpSectionHeaders working with tabs ......................................................................
[bugfix][TEST] cc: Get cleanUpSectionHeaders working with tabs
+ limit heading level to MediaWiki's maximum of 6 + fix regex for headings containing equal sign + replace actual tab character in tests by escape sequence
Bug: T185392 Change-Id: I0bafdf3db015d3bca7622219085307d524b51ee7 --- M pywikibot/cosmetic_changes.py M tests/cosmetic_changes_tests.py 2 files changed, 8 insertions(+), 2 deletions(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index 009eed5..a3dee44 100755 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -649,7 +649,7 @@ return text return textlib.replaceExcept( text, - r'(?m)^(={1,7}) *(?P<title>[^=]+?) *\1 *\r?\n', + r'(?m)^(={1,6})[ \t]*(?P<title>.*[^\s=])[ \t]*\1[ \t]*\r?\n', r'\1 \g<title> \1%s' % config.LS, ['comment', 'math', 'nowiki', 'pre'])
diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py index 6e22088..64c6a34 100644 --- a/tests/cosmetic_changes_tests.py +++ b/tests/cosmetic_changes_tests.py @@ -72,7 +72,7 @@ self.cct.removeUselessSpaces(' Foo bar ')) # tab self.assertEqual('Fooooo bar', - self.cct.removeUselessSpaces('Fooooo bar ')) + self.cct.removeUselessSpaces('Fooooo bar\t'))
def test_removeNonBreakingSpaceBeforePercent(self): """Test removeNonBreakingSpaceBeforePercent method.""" @@ -83,6 +83,12 @@ """Test cleanUpSectionHeaders method.""" self.assertEqual('=== Header ===\n', self.cct.cleanUpSectionHeaders('===Header===\n')) + # tab + self.assertEqual('=== Header ===\n', + self.cct.cleanUpSectionHeaders('===Header===\t\n')) + # tabs inside + self.assertEqual('=== Header ===\n', + self.cct.cleanUpSectionHeaders('===\tHeader\t===\n'))
def test_putSpacesInLists(self): """Test putSpacesInLists method."""
pywikibot-commits@lists.wikimedia.org