testparseutil: escape backslash in docstring
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 04 Feb 2019 14:16:52 -0800
changeset 41566 99b4c6d73a72
parent 41565 033a0f4b4a5f
child 41567 eb14ab7db33e
testparseutil: escape backslash in docstring This is funky. This inline Python code is part of a docstring, which means the string is interpreted first. So any backslashes need double escaping. So even though this is already a br'', we still need to escape. Differential Revision: https://phab.mercurial-scm.org/D5842
contrib/testparseutil.py
--- a/contrib/testparseutil.py	Mon Feb 04 14:14:25 2019 -0800
+++ b/contrib/testparseutil.py	Mon Feb 04 14:16:52 2019 -0800
@@ -265,7 +265,7 @@
 class fileheredocmatcher(embeddedmatcher):
     """Detect "cat > FILE << LIMIT" style embedded code
 
-    >>> matcher = fileheredocmatcher(b'heredoc .py file', br'[^<]+\.py')
+    >>> matcher = fileheredocmatcher(b'heredoc .py file', br'[^<]+\\.py')
     >>> b2s(matcher.startsat(b'  $ cat > file.py << EOF\\n'))
     ('file.py', '  > EOF\\n')
     >>> b2s(matcher.startsat(b'  $ cat   >>file.py   <<EOF\\n'))