A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-August/121356.html below:

Add yet another test for subprocess.Popen.communicate

[Python-Dev] cpython: Add yet another test for subprocess.Popen.communicateAntoine Pitrou solipsis at pitrou.net
Thu Aug 16 00:25:42 CEST 2012
On Wed, 15 Aug 2012 21:54:06 +0200 (CEST)
andrew.svetlov <python-checkins at python.org> wrote:
> 
> diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
> --- a/Lib/test/test_subprocess.py
> +++ b/Lib/test/test_subprocess.py
> @@ -645,6 +645,34 @@
>          p.communicate()
>          self.assertEqual(p.returncode, 0)
>  
> +    def test_universal_newlines_communicate_stdin_stdout_stderr(self):
> +        # universal newlines through communicate(), with only stdin
> +        p = subprocess.Popen([sys.executable, "-c",
> +                              'import sys,os;' + SETBINARY + '''\nif True:
> +                                  s = sys.stdin.readline()
> +                                  sys.stdout.write(s)
> +                                  sys.stdout.write("line2\\r")
> +                                  sys.stderr.write("eline2\\n")
> +                                  s = sys.stdin.read()
> +                                  sys.stdout.write(s+"line4\\n")
> +                                  sys.stdout.write(s+"line5\\r\\n")
> +                                  sys.stderr.write("eline6\\n")
> +                                  sys.stderr.write("eline7\\r")
> +                                  sys.stderr.write("eline8\\r\\n")
> +                              '''],

This test is wrong. You need to write your test data as binary data on
the binary output streams, as in the other tests. Using the text
output streams introduces a spurious line ending conversion, which makes
the test fail under Windows:
http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.x/builds/486

> +        # Python debug build push something like "[42442 refs]\n"
> +        # to stderr at exit of subprocess.
> +        self.assertTrue(stderr.startswith("eline2\neline6\neline7\neline8\n"))

You should use self.assertStderrEqual() instead.

Regards

Antoine.


-- 
Software development and contracting: http://pro.pitrou.net


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4