Skip to content

Commit a4ababc

Browse files
author
Release Manager
committed
sagemathgh-39647: Redirect warning output from stderr to stdout in doctests <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Pytest considers ouput in `stderr` as errors, thus we redirect the doctest warnings to `stdout` instead. Doesn't seem to make a difference for sage's doctest runner. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39647 Reported by: Tobias Diez Reviewer(s):
2 parents ca989cf + 5d573c3 commit a4ababc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/sage/doctest/forker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ def showwarning_with_traceback(message, category, filename, lineno, file=None, l
261261
r"""
262262
Displays a warning message with a traceback.
263263
264-
INPUT: see :func:`warnings.showwarning`.
264+
INPUT: see :func:`warnings.showwarning` with the difference that with ``file=None``
265+
the message will be written to stdout.
265266
266267
OUTPUT: none
267268
@@ -293,7 +294,7 @@ def showwarning_with_traceback(message, category, filename, lineno, file=None, l
293294
lines.extend(traceback.format_exception_only(category, category(message)))
294295

295296
if file is None:
296-
file = sys.stderr
297+
file = sys.stdout
297298
try:
298299
file.writelines(lines)
299300
file.flush()

0 commit comments

Comments
 (0)