Benjamin Schubert pushed to branch bschubert/fix-binary-output-capture at BuildStream / buildstream
Commits:
-
b7806c7d
by Benjamin Schubert at 2018-10-26T14:42:21Z
1 changed file:
Changes:
| ... | ... | @@ -17,7 +17,7 @@ import pytest |
| 17 | 17 |
# CliRunner convenience API (click.testing module) does not support
|
| 18 | 18 |
# separation of stdout/stderr.
|
| 19 | 19 |
#
|
| 20 |
-from _pytest.capture import MultiCapture, FDCapture
|
|
| 20 |
+from _pytest.capture import FDCapture
|
|
| 21 | 21 |
|
| 22 | 22 |
# Import the main cli entrypoint
|
| 23 | 23 |
from buildstream._frontend import cli as bst_cli
|
| ... | ... | @@ -306,8 +306,11 @@ class Cli(): |
| 306 | 306 |
with open(os.devnull) as devnull:
|
| 307 | 307 |
sys.stdin = devnull
|
| 308 | 308 |
|
| 309 |
- capture = MultiCapture(out=True, err=True, in_=False, Capture=FDCapture)
|
|
| 310 |
- capture.start_capturing()
|
|
| 309 |
+ capture_stdout = FDCapture(1)
|
|
| 310 |
+ capture_stderr = FDCapture(2)
|
|
| 311 |
+ |
|
| 312 |
+ capture_stdout.start()
|
|
| 313 |
+ capture_stderr.start()
|
|
| 311 | 314 |
|
| 312 | 315 |
try:
|
| 313 | 316 |
cli.main(args=args or (), prog_name=cli.name, **extra)
|
| ... | ... | @@ -331,8 +334,12 @@ class Cli(): |
| 331 | 334 |
sys.stdout.flush()
|
| 332 | 335 |
|
| 333 | 336 |
sys.stdin = old_stdin
|
| 334 |
- out, err = capture.readouterr()
|
|
| 335 |
- capture.stop_capturing()
|
|
| 337 |
+ |
|
| 338 |
+ out = capture_stdout.snap()
|
|
| 339 |
+ err = capture_stderr.snap()
|
|
| 340 |
+ |
|
| 341 |
+ capture_stdout.done()
|
|
| 342 |
+ capture_stderr.done()
|
|
| 336 | 343 |
|
| 337 | 344 |
return Result(exit_code=exit_code,
|
| 338 | 345 |
exception=exception,
|
