comparison tests/run-tests.py @ 43801:3fe91bcd5199

tests: fix deprecation warning about regex flags not at beginning of expr 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. Differential Revision: https://phab.mercurial-scm.org/D7552
author Kyle Lippincott <spectral@google.com>
date Thu, 05 Dec 2019 14:01:26 -0800
parents ac140b85aae9
children e8a3bbffdc7d
comparison
equal deleted inserted replaced
43800:fe94af4e3dc9 43801:3fe91bcd5199
1971 return pos, postout 1971 return pos, postout
1972 1972
1973 @staticmethod 1973 @staticmethod
1974 def rematch(el, l): 1974 def rematch(el, l):
1975 try: 1975 try:
1976 el = b'(?:' + el + b')' 1976 # parse any flags at the beginning of the regex. Only 'i' is
1977 # supported right now, but this should be easy to extend.
1978 flags, el = re.match(br'^(\(\?i\))?(.*)', el).groups()[0:2]
1979 flags = flags or b''
1980 el = flags + b'(?:' + el + b')'
1977 # use \Z to ensure that the regex matches to the end of the string 1981 # use \Z to ensure that the regex matches to the end of the string
1978 if os.name == 'nt': 1982 if os.name == 'nt':
1979 return re.match(el + br'\r?\n\Z', l) 1983 return re.match(el + br'\r?\n\Z', l)
1980 return re.match(el + br'\n\Z', l) 1984 return re.match(el + br'\n\Z', l)
1981 except re.error: 1985 except re.error: