Commit 6e31304d authored by Kirill Smelkov's avatar Kirill Smelkov

golang: tests: Don't hide output details in assert on retcode of spawned command

For example if test_defer_excchain_dump_ipython fails the output was:

    >       assert retcode == 0
    E       assert 1 == 0

and it was unclear what was going on. Now the output is e.g.

    >       assert retcode == 0, (stdout, stderr)
    E       AssertionError: ('', '==152924==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
    E         ')
    E       assert 1 == 0

Amends: 09629367 (golang: tests: Add tests for IPython and Pytest
integration patches) and bb9a94c3 (golang: Teach defer to chain
exceptions (PEP 3134) even on Python2).
parent a6b993c8
...@@ -1650,7 +1650,7 @@ def test_defer_excchain_dump(): ...@@ -1650,7 +1650,7 @@ def test_defer_excchain_dump():
tbok = readfile(dir_testprog + "/golang_test_defer_excchain.txt") tbok = readfile(dir_testprog + "/golang_test_defer_excchain.txt")
retcode, stdout, stderr = _pyrun(["golang_test_defer_excchain.py"], retcode, stdout, stderr = _pyrun(["golang_test_defer_excchain.py"],
cwd=dir_testprog, stdout=PIPE, stderr=PIPE) cwd=dir_testprog, stdout=PIPE, stderr=PIPE)
assert retcode != 0 assert retcode != 0, (stdout, stderr)
assert stdout == b"" assert stdout == b""
assertDoc(tbok, stderr) assertDoc(tbok, stderr)
...@@ -1661,7 +1661,7 @@ def test_defer_excchain_dump_ipython(): ...@@ -1661,7 +1661,7 @@ def test_defer_excchain_dump_ipython():
"-m", "golang_test_defer_excchain"], "-m", "golang_test_defer_excchain"],
env={"COLUMNS": "80"}, # force ipython5 avoid thinking termwidth=0 env={"COLUMNS": "80"}, # force ipython5 avoid thinking termwidth=0
cwd=dir_testprog, stdout=PIPE, stderr=PIPE) cwd=dir_testprog, stdout=PIPE, stderr=PIPE)
assert retcode == 0 assert retcode == 0, (stdout, stderr)
# ipython5 uses .pyc for filenames instead of .py # ipython5 uses .pyc for filenames instead of .py
stdout = re.sub(br'\.pyc\b', b'.py', stdout) # normalize .pyc -> .py stdout = re.sub(br'\.pyc\b', b'.py', stdout) # normalize .pyc -> .py
assertDoc(tbok, stdout) assertDoc(tbok, stdout)
...@@ -1673,7 +1673,7 @@ def test_defer_excchain_dump_pytest(): ...@@ -1673,7 +1673,7 @@ def test_defer_excchain_dump_pytest():
retcode, stdout, stderr = _pyrun(["-m", "pytest", "-o", "python_functions=main", retcode, stdout, stderr = _pyrun(["-m", "pytest", "-o", "python_functions=main",
"--tb=short", "golang_test_defer_excchain.py"], "--tb=short", "golang_test_defer_excchain.py"],
cwd=dir_testprog, stdout=PIPE, stderr=PIPE) cwd=dir_testprog, stdout=PIPE, stderr=PIPE)
assert retcode != 0 assert retcode != 0, (stdout, stderr)
assert stderr == b"" assert stderr == b""
assertDoc(tbok, stdout) assertDoc(tbok, stdout)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment