XZise has submitted this change and it was merged.
Change subject: Fix py3 textlib remaining issues in tests ......................................................................
Fix py3 textlib remaining issues in tests
'_' and ':' do not need to be escaped in Regular Expressions, depending on where they appear, but re.escape may escape them, and py < 2 does.
Change-Id: I0f00000ff3fc09f9f8a21d1f23fd0d756f5332b1 --- M pywikibot/textlib.py M tests/textlib_tests.py 2 files changed, 2 insertions(+), 5 deletions(-)
Approvals: XZise: Looks good to me, approved
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index 10088ac..9a2bd23 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -1132,9 +1132,9 @@ text link e.g. for categories and files. """ # match preceding colon for text links - section = re.sub(r'\[\[(\:)?', '[[:?', re.escape(section)) + section = re.sub(r'\[\[(\:)?', '[[:?', re.escape(section)) # match underscores and white spaces - section = re.sub(r'\[ _]', '[ _]', section) + section = re.sub(r'\?[ _]', '[ _]', section) m = re.search("=+[ ']*%s[ ']*=+" % section, pagetext) return bool(m)
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index d4586e5..b22126b 100644 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -11,7 +11,6 @@ except ImportError: mwparserfromhell = False import codecs -import sys import os
import pywikibot @@ -66,7 +65,6 @@ self.assertEqual(func('{{a|b|c=d}}'), [('a', {u'1': 'b', 'c': 'd'})]) self.assertEqual(func('{{a|b={{c}}}}'), [('c', {}), (u'a', {u'b': u'{{c}}'})])
- @unittest.skipIf(sys.version_info[0] > 2, "Fails on Python 3") def testSpacesInSection(self): self.assertContains("enwiki_help_editing", u"Minor_edits") self.assertNotContains("enwiki_help_editing", u"#Minor edits", "Incorrect, '#Minor edits' does not work") @@ -78,7 +76,6 @@ self.assertContains("enwiki_help_editing", u"Talk_.28discussion.29_pages", "As used in the TOC") self.assertContains("enwiki_help_editing", u"Talk_(discussion)_pages", "Understood by mediawiki")
- @unittest.skipIf(sys.version_info[0] > 2, "Fails on Python 3") def test_spaces_outside_section(self): self.assertContains("enwiki_help_editing", u"Naming and_moving") self.assertContains("enwiki_help_editing", u" Naming and_moving ")
pywikibot-commits@lists.wikimedia.org