Stderr with merge_streams Test

This page tests how the stderr warning feature handles the merge_streams option in myst-nb.

Test Case 1: merge_streams=False (default) - Separate stderr class

When merge_streams is False, stderr gets its own .output.stderr element. Our feature SHOULD collapse this.

print("Normal output")
warnings.warn("This is a warning")
Normal output
UserWarning: This is a warning
  warnings.warn("This is a warning")

Test Case 2: merge_streams=True - Combined in .output.stream

When merge_streams is True, myst-nb combines stdout and stderr into a single .output.stream element. Our feature should NOT collapse this since there's no .output.stderr class.

print("Normal output")
warnings.warn("This is a warning")
Normal output
UserWarning: This is a warning
  warnings.warn("This is a warning")

Test Case 3: Only stderr with merge_streams=True

Even when merge_streams is True, if a cell ONLY produces stderr (no stdout), it should still use .output.stderr class and our feature SHOULD collapse it.

warnings.warn("Only a warning, no stdout")
UserWarning: Only a warning, no stdout
  warnings.warn("Only a warning, no stdout")

Expected Behavior Summary

Key insight: When merge_streams=True, myst-nb combines stdout and stderr into a single .output.stream element. Our feature only targets .output.stderr elements, so merged streams will display normally. This is the correct behavior because: