D7552: tests: fix deprecation warning about regex flags not at beginning of expr

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Thu Dec 5 19:09:42 EST 2019


spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This may only show up when running the tests under python3.6+. Currently the
  only test that does this is test-patchbomb-tls.t, and it only uses (?i), so
  that's all that's handled at the moment.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7552

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1973,7 +1973,11 @@
     @staticmethod
     def rematch(el, l):
         try:
-            el = b'(?:' + el + b')'
+            # parse any flags at the beginning of the regex. Only 'i' is
+            # supported right now, but this should be easy to extend.
+            flags, el = re.match(br'^(\(\?i\))?(.*)', el).groups()[0:2]
+            flags = flags or b''
+            el = flags + b'(?:' + el + b')'
             # use \Z to ensure that the regex matches to the end of the string
             if os.name == 'nt':
                 return re.match(el + br'\r?\n\Z', l)



To: spectral, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list