From a79f0e50bb33eac87ed7f64418c2889be2e0fbf5 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sat, 21 Sep 2019 07:27:39 +0000 Subject: [PATCH] tests/gclient_scm_test.py: Fix invalid escape sequences in regex strings Note that on line 504 I also fixed the test on windows by allowing \. Also properly escaped /. Errors: C:\Google\depot_tools\tests\gclient_scm_test.py:42: SyntaxWarning: invalid escape sequence \[ TIMESTAMP_RE = re.compile('\[[0-9]{1,2}:[0-9]{2}:[0-9]{2}\] (.*)', re.DOTALL) C:\Google\depot_tools\tests\gclient_scm_test.py:504: SyntaxWarning: invalid escape sequence \. "breaking lock.*\.git/index\.lock") Bug: 958138 Change-Id: I19ef98538a1c172d7139ca2d7097a7fbc33ebe80 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1815866 Commit-Queue: Raul Tambre Reviewed-by: Edward Lesmes Auto-Submit: Raul Tambre --- tests/gclient_scm_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 2a4f3d9a78..44704648e1 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -39,7 +39,7 @@ git_cache.Mirror.SetCachePath(None) # Shortcut since this function is used often join = gclient_scm.os.path.join -TIMESTAMP_RE = re.compile('\[[0-9]{1,2}:[0-9]{2}:[0-9]{2}\] (.*)', re.DOTALL) +TIMESTAMP_RE = re.compile(r'\[[0-9]{1,2}:[0-9]{2}:[0-9]{2}\] (.*)', re.DOTALL) def strip_timestamps(value): lines = value.splitlines(True) for i in range(len(lines)): @@ -501,7 +501,7 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): pass scm.update(options, (), []) self.assertRegexpMatches(sys.stdout.getvalue(), - "breaking lock.*\.git/index\.lock") + r'breaking lock.*\.git[/|\\]index\.lock') self.assertFalse(os.path.exists(file_path)) sys.stdout.close()