Skip to content

Commit

Permalink
Show doctest failures in the traceback.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice committed Jan 14, 2022
1 parent 3110606 commit f9512ad
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions python/cudf/cudf/tests/test_doctests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import contextlib
import doctest
import inspect
import io
import os

import numpy as np
Expand Down Expand Up @@ -89,6 +91,12 @@ def test_docstring(self, docstring):
globals = dict(cudf=cudf, np=np,)
docstring.globs = globals

runner.run(docstring)
results = runner.summarize()
assert not results.failed, results
# Capture stdout and include failing outputs in the traceback.
doctest_stdout = io.StringIO()
with contextlib.redirect_stdout(doctest_stdout):
runner.run(docstring)
results = runner.summarize()
assert not results.failed, (
f"{results.failed} of {results.attempted} doctests failed for "
f"{docstring.name}:\n{doctest_stdout.getvalue()}"
)

0 comments on commit f9512ad

Please sign in to comment.