Skip to content

Commit 22a9278

Browse files
author
Vladimir Kotal
committed
better output size computation
1 parent 569dc7b commit 22a9278

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

opengrok-tools/src/test/python/test_command.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,25 +175,27 @@ def test_long_output():
175175
"""
176176
Test that output thread in the Command class captures all of the output.
177177
(and also it does not hang the command by filling up the pipe)
178+
179+
By default stderr is redirected to stdout.
178180
"""
179181
# in bytes, should be enough to fill a pipe
180-
num_lines = 500
182+
num_lines = 5000
181183
line_length = 1000
184+
num_bytes = num_lines * (line_length + 1)
182185
with tempfile.NamedTemporaryFile() as file:
183186
for _ in range(num_lines):
184187
file.write(b'A' * line_length)
185188
file.write(b'\n')
186189
file.flush()
187-
assert os.path.getsize(file.name) == num_lines * (line_length + 1)
190+
assert os.path.getsize(file.name) == num_bytes
188191

189192
cmd = Command(["/bin/cat", file.name])
190193
cmd.execute()
191194

192195
assert cmd.getstate() == Command.FINISHED
193196
assert cmd.getretcode() == 0
194197
assert cmd.geterroutput() is None
195-
# -1 because getoutputstr() strips the string
196-
assert len(cmd.getoutputstr()) == num_lines * (line_length + 1) - 1
198+
assert len("".join(cmd.getoutput())) == num_bytes
197199

198200

199201
@pytest.mark.skipif(not os.name.startswith("posix"), reason="requires posix")

0 commit comments

Comments
 (0)