Skip to content

Commit d21f07b

Browse files
committed
add some meaningful output to the assertion
1 parent 1ebeb54 commit d21f07b

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

test/test_scorep.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ def call(arguments, expected_returncode=0, env=None):
1919
arguments, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE
2020
)
2121
print(out.stdout, out.stderr)
22-
assert out.returncode == expected_returncode
22+
try:
23+
assert out.returncode == expected_returncode
24+
except AssertionError as e:
25+
e.args += "stderr: {}".format(out.stderr.decode("utf-8"))
26+
raise
2327
stdout, stderr = (out.stdout, out.stderr)
2428
else:
2529
p = subprocess.Popen(
2630
arguments, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE
2731
)
2832
stdout, stderr = p.communicate()
29-
assert p.returncode == expected_returncode
33+
try:
34+
assert p.returncode == expected_returncode
35+
except AssertionError as e:
36+
e.args += "stderr: {}".format(stderr.decode("utf-8"))
37+
raise
3038
return stdout.decode("utf-8"), stderr.decode("utf-8")
3139

3240

@@ -51,8 +59,8 @@ def requires_package(name):
5159

5260

5361
cinstrumenter_skip_mark = pytest.mark.skipif(
54-
sys.version_info.major < 3 or platform.python_implementation() == 'PyPy',
55-
reason="CInstrumenter only available in Python 3 and not in PyPy"
62+
sys.version_info.major < 3 or platform.python_implementation() == "PyPy",
63+
reason="CInstrumenter only available in Python 3 and not in PyPy",
5664
)
5765
# All instrumenters (except dummy which isn't a real one)
5866
ALL_INSTRUMENTERS = [
@@ -90,6 +98,7 @@ def test_has_version():
9098
@cinstrumenter_skip_mark
9199
def test_has_c_instrumenter():
92100
from scorep.instrumenter import has_c_instrumenter
101+
93102
assert has_c_instrumenter()
94103

95104

0 commit comments

Comments
 (0)