Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect warning output from stderr to stdout in doctests #39647

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/sage/doctest/forker.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@
r"""
Displays a warning message with a traceback.

INPUT: see :func:`warnings.showwarning`.
INPUT: see :func:`warnings.showwarning` with the difference that with ``file=None``
the message will be written to stdout.

OUTPUT: none

Expand Down Expand Up @@ -293,7 +294,7 @@
lines.extend(traceback.format_exception_only(category, category(message)))

if file is None:
file = sys.stderr
file = sys.stdout
try:
file.writelines(lines)
file.flush()
Expand Down Expand Up @@ -2193,7 +2194,7 @@
sage: W.start()
sage: DC = DocTestController(DD, filename)
sage: reporter = DocTestReporter(DC)
sage: W.join() # Wait for worker to finish

Check warning on line 2197 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2197 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 2197 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
sage: result = W.result_queue.get()
sage: reporter.report(FDS, False, W.exitcode, result, "")
[... tests, ...s wall]
Expand Down Expand Up @@ -2320,7 +2321,7 @@
....: except OSError:
....: print("Write end of pipe successfully closed")
Write end of pipe successfully closed
sage: W.join() # Wait for worker to finish

Check warning on line 2324 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2324 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 2324 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
"""
super().start()

Expand Down Expand Up @@ -2356,7 +2357,7 @@
sage: W.start()
sage: while W.rmessages is not None:
....: W.read_messages()
sage: W.join()

Check warning on line 2360 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2360 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 2360 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
sage: len(W.messages) > 0
True
"""
Expand Down Expand Up @@ -2388,7 +2389,7 @@
sage: FDS = FileDocTestSource(filename, DD)
sage: W = DocTestWorker(FDS, DD)
sage: W.start()
sage: W.join()

Check warning on line 2392 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2392 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 2392 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
sage: W.save_result_output()
sage: sorted(W.result[1].keys())
['cputime', 'err', 'failures', 'optionals', 'tests', 'walltime', 'walltime_skips']
Expand Down
Loading