Skip to content

Commit e66d436

Browse files
committed
[GR-54135] Give better error message when asserts fail in test_subprocess.py
1 parent 972884f commit e66d436

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_subprocess.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
# Copyright (C) 1996-2017 Python Software Foundation
33
#
44
# Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -144,39 +144,39 @@ def test_graal_python_args(self):
144144

145145
env = {"GRAAL_PYTHON_ARGS": "-c 12"}
146146
result = subprocess.run([sys.executable], env=env)
147-
assert result.returncode == 0
147+
self.assertEqual(0, result.returncode)
148148

149149
env = {"GRAAL_PYTHON_ARGS": "-c 'print(12)'"}
150150
result = subprocess.check_output([sys.executable], env=env, text=True)
151-
assert result == '12\n'
151+
self.assertEqual('12\n', result)
152152

153153
env = {"GRAAL_PYTHON_ARGS": """-c 'print("Hello world")'"""}
154154
result = subprocess.check_output([sys.executable], env=env, text=True)
155-
assert result == 'Hello world\n'
155+
self.assertEqual('Hello world\n', result)
156156

157157
env = {"GRAAL_PYTHON_ARGS": """-c ""'print("Hello world")'"""""}
158158
result = subprocess.check_output([sys.executable], env=env, text=True)
159-
assert result == 'Hello world\n'
159+
self.assertEqual('Hello world\n', result)
160160

161161
env = {"GRAAL_PYTHON_ARGS": r"""-c 'print(\'"Hello world"\')'"""""}
162162
result = subprocess.check_output([sys.executable], env=env, text=True)
163-
assert result == '"Hello world"\n'
163+
self.assertEqual('"Hello world"\n', result)
164164

165165
env = {"GRAAL_PYTHON_ARGS": """\v-c\vprint('"Hello world"')"""}
166166
result = subprocess.check_output([sys.executable], env=env, text=True)
167-
assert result == '"Hello world"\n'
167+
self.assertEqual('"Hello world"\n', result)
168168

169169
env = {"GRAAL_PYTHON_ARGS": """\v-c\vprint('Hello', "world")"""}
170170
result = subprocess.check_output([sys.executable], env=env, text=True)
171-
assert result == 'Hello world\n'
171+
self.assertEqual('Hello world\n', result)
172172

173173
# check that the subprocess receives the args and thus it should fail because it recurses
174174
args = """\v-c\vimport os\nprint(os.environ.get("GRAAL_PYTHON_ARGS"))"""
175175
env = {"GRAAL_PYTHON_ARGS": args}
176176
result = subprocess.check_output([sys.executable], env=env, text=True)
177-
assert result == f"{args}\n"
177+
self.assertEqual(f"{args}\n", result)
178178

179179
# check that the subprocess does not receive the args when we end with \v
180180
env = {"GRAAL_PYTHON_ARGS": """\v-c\vimport os\nprint(os.environ.get("GRAAL_PYTHON_ARGS"))\v"""}
181181
result = subprocess.check_output([sys.executable], env=env, text=True)
182-
assert result == 'None\n'
182+
self.assertEqual('None\n', result)

0 commit comments

Comments
 (0)