Check stdout and stderr separately
A command-line component has several observable outputs. Stdout carries its result, while stderr can carry diagnostics. Keeping those channels separate lets another program consume the result without parsing a warning out of it.
Pytest's capsys fixture captures the streams and readouterr returns both values. Reading also clears the captured buffers for the next observation. As with other fixtures, pytest must execute the test; merely defining the function does not exercise it. Use exact short outputs here so a swapped channel or missing newline produces a useful failure.
import contextlib, io, sys
out, err = io.StringIO(), io.StringIO()
with contextlib.redirect_stdout(out):
with contextlib.redirect_stderr(err):
print("result")
print("warning", file=sys.stderr)
print(repr(out.getvalue()))
print(repr(err.getvalue()))Your task
Implement output_suite(implementation): append a pytest test using capsys to source defining emit(). Calling emit() must print exactly "result " to stdout and "warning " to stderr. Return pytest exit code.
The explanation opens here once every check passes.