diff options
author | JensDiemer <git@jensdiemer.de> | 2015-06-02 20:24:23 +0200 |
---|---|---|
committer | JensDiemer <git@jensdiemer.de> | 2015-06-02 20:24:23 +0200 |
commit | 98809541577b9ea2e6161288929f4dcb76038973 (patch) | |
tree | 1d6620afc23caac267b343345c4c67c66bbb6291 /creole | |
parent | 05656188f91e61622bcf93eba8a8bc0d7636ef41 (diff) | |
download | creole-98809541577b9ea2e6161288929f4dcb76038973.tar.gz |
Fix unittests:
merge subprocess stdout and stderr to make tests easier...
Note: "argparse --version" will use stderr in older python versions
and stdout in newer python versions
see: https://travis-ci.org/jedie/python-creole/builds/65109263
Diffstat (limited to 'creole')
-rw-r--r-- | creole/tests/test_cli.py | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/creole/tests/test_cli.py b/creole/tests/test_cli.py index 52014bf..5b40529 100644 --- a/creole/tests/test_cli.py +++ b/creole/tests/test_cli.py @@ -53,7 +53,8 @@ class CreoleCLITests(BaseCreoleTest): print("Call:", popen_args) process = subprocess.Popen(popen_args, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, universal_newlines=True, ) stdout, stderr = process.communicate() @@ -65,14 +66,12 @@ class CreoleCLITests(BaseCreoleTest): print("stderr: %r" % stderr) stdout = stdout.strip() - stderr = stderr.strip() - return popen_args, retcode, stdout, stderr + return popen_args, retcode, stdout - def assertSubprocess(self, popen_args, retcode, stdout, stderr, verbose=True): - popen_args2, retcode2, stdout2, stderr2 = self._subprocess(popen_args, verbose) + def assertSubprocess(self, popen_args, retcode, stdout, verbose=True): + popen_args2, retcode2, stdout2 = self._subprocess(popen_args, verbose) try: self.assertEqual(stdout, stdout2, "stdout wrong:") - self.assertEqual(stderr, stderr2, "stderr wrong:") self.assertEqual(retcode, retcode2, "return code wrong:") except AssertionError as err: msg = ( @@ -81,13 +80,11 @@ class CreoleCLITests(BaseCreoleTest): "return code........: %r\n" " ---------- [stdout] ---------- \n" "%s\n" - " ---------- [stderr] ---------- \n" - "%s\n" "-------------------------------" ) % ( err, repr(popen_args2), retcode2, - stdout2, stderr2, + stdout2, ) self.fail(msg) @@ -114,7 +111,7 @@ class CreoleCLITests(BaseCreoleTest): self.assertSubprocess( popen_args=[cli_str, sourcefilepath, destfilepath], - retcode=0, stdout=stdout, stderr="", + retcode=0, stdout=stdout, verbose=False, ) @@ -130,22 +127,12 @@ class CreoleCLITests(BaseCreoleTest): version_info = "%s from python-creole v%s" % ( cmd, VERSION_STRING ) - if PY3: - self.assertSubprocess( - popen_args=[cmd, "--version"], - retcode=0, - stdout=version_info, - stderr="", - verbose=False, - ) - else: - self.assertSubprocess( - popen_args=[cmd, "--version"], - retcode=0, - stdout="", - stderr=version_info, - verbose=False, - ) + self.assertSubprocess( + popen_args=[cmd, "--version"], + retcode=0, + stdout=version_info, + verbose=False, + ) def test_creole2html(self): self._test_convert( |