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 <raul@tambre.ee>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
index 2a4f3d9..4470464 100755
--- a/tests/gclient_scm_test.py
+++ b/tests/gclient_scm_test.py
@@ -39,7 +39,7 @@
# 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 @@
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()