jenkins-bot has submitted this change and it was merged.
Change subject: replaceExcept tests for non-inverting lookbehind or lookbehind
......................................................................
replaceExcept tests for non-inverting lookbehind or lookbehind
Bug: T123185
Change-Id: I1c0dba18e8db1bf1556c94dfb17e9a3b7dc45801
---
M tests/textlib_tests.py
1 file changed, 20 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 00bf1f8..8c6f572 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -1026,6 +1026,26 @@
textlib.replaceExcept('A123B', r'A(?P<a>\d)2(\d)B',
r'A\g<a>x\2B', [], site=self.site),
'A1x3B')
+ # test regex with lookbehind.
+ self.assertEqual(
+ textlib.replaceExcept('A behindB C', r'(?<=behind)\w',
+ r'Z', [], site=self.site),
+ 'A behindZ C')
+ # test regex with lookbehind and groups.
+ self.assertEqual(
+ textlib.replaceExcept('A behindB C D', r'(?<=behind)\w(
)',
+ r'\g<1>Z', [], site=self.site),
+ 'A behind ZC D')
+ # test regex with lookahead.
+ self.assertEqual(
+ textlib.replaceExcept('A Bahead C', r'\w(?=ahead)',
+ r'Z', [], site=self.site),
+ 'A Zahead C')
+ # test regex with lookahead and groups.
+ self.assertEqual(
+ textlib.replaceExcept('A Bahead C D', r'( )\w(?=ahead)',
+ r'Z\g<1>', [], site=self.site),
+ 'AZ ahead C D')
def test_case_sensitive(self):
"""Test replacing with different case
sensitivity."""
--
To view, visit
https://gerrit.wikimedia.org/r/266600
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1c0dba18e8db1bf1556c94dfb17e9a3b7dc45801
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>