Patchwork [2,of,2,V2] heredoctest: do not append extra newline character to continuation line

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 29, 2014, 12:17 p.m.
Message ID <b3d680392bafa5a3e810.1411993048@mimosa>
Download mbox | patch
Permalink /patch/6027/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 29, 2014, 12:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1411884815 -32400
#      Sun Sep 28 15:13:35 2014 +0900
# Node ID b3d680392bafa5a3e81009bf2093602936dff623
# Parent  6a5197528c81966ff4c1417a4c9ae4489cb368a4
heredoctest: do not append extra newline character to continuation line

Trailing newline characters are kept in lines.
Augie Fackler - Sept. 29, 2014, 6:43 p.m.
On Mon, Sep 29, 2014 at 09:17:28PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1411884815 -32400
> #      Sun Sep 28 15:13:35 2014 +0900
> # Node ID b3d680392bafa5a3e81009bf2093602936dff623
> # Parent  6a5197528c81966ff4c1417a4c9ae4489cb368a4
> heredoctest: do not append extra newline character to continuation line

These look good, queued.

(Will now look at remainder of the v1 series.)

>
> Trailing newline characters are kept in lines.
>
> diff --git a/tests/heredoctest.py b/tests/heredoctest.py
> --- a/tests/heredoctest.py
> +++ b/tests/heredoctest.py
> @@ -10,7 +10,7 @@ while lines:
>          snippet = l[4:]
>          while lines and lines[0].startswith('... '):
>              l = lines.pop(0)
> -            snippet += "\n" + l[4:]
> +            snippet += l[4:]
>          c = compile(snippet, '<heredoc>', 'single')
>          try:
>              exec c in globalvars
> diff --git a/tests/test-unified-test.t b/tests/test-unified-test.t
> --- a/tests/test-unified-test.t
> +++ b/tests/test-unified-test.t
> @@ -42,6 +42,10 @@ Doctest commands:
>    ...     print foo, 'should be visible in func()'
>    >>> func()
>    global name should be visible in func()
> +  >>> print '''multiline
> +  ... string'''
> +  multiline
> +  string
>
>  Regular expressions:
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/tests/heredoctest.py b/tests/heredoctest.py
--- a/tests/heredoctest.py
+++ b/tests/heredoctest.py
@@ -10,7 +10,7 @@  while lines:
         snippet = l[4:]
         while lines and lines[0].startswith('... '):
             l = lines.pop(0)
-            snippet += "\n" + l[4:]
+            snippet += l[4:]
         c = compile(snippet, '<heredoc>', 'single')
         try:
             exec c in globalvars
diff --git a/tests/test-unified-test.t b/tests/test-unified-test.t
--- a/tests/test-unified-test.t
+++ b/tests/test-unified-test.t
@@ -42,6 +42,10 @@  Doctest commands:
   ...     print foo, 'should be visible in func()'
   >>> func()
   global name should be visible in func()
+  >>> print '''multiline
+  ... string'''
+  multiline
+  string
 
 Regular expressions: