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
Allow doctest_show_success=False option #10938
Allow doctest_show_success=False option #10938
Conversation
@@ -454,21 +454,23 @@ def condition(node: Node) -> bool: | |||
if not groups: | |||
return | |||
|
|||
self._out('\nDocument: %s\n----------%s\n' % | |||
(docname, '-' * len(docname))) | |||
if self.config.doctest_show_successes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.config.doctest_show_successes: | |
show_successes = self.config.doctest_show_successes | |
if show_successes : |
for group in groups.values(): | ||
self.test_group(group) | ||
# Separately count results from setup code | ||
res_f, res_t = self.setup_runner.summarize(self._out, verbose=False) | ||
self.setup_failures += res_f | ||
self.setup_tries += res_t | ||
if self.test_runner.tries: | ||
res_f, res_t = self.test_runner.summarize(self._out, verbose=True) | ||
res_f, res_t = self.test_runner.summarize( | ||
self._out, verbose=self.config.doctest_show_successes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._out, verbose=self.config.doctest_show_successes) | |
self._out, verbose=show_successes) |
res_f, res_t = self.cleanup_runner.summarize(self._out, | ||
verbose=True) | ||
res_f, res_t = self.cleanup_runner.summarize( | ||
self._out, verbose=self.config.doctest_show_successes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._out, verbose=self.config.doctest_show_successes) | |
self._out, verbose=show_successes) |
@@ -555,6 +557,7 @@ def setup(app: "Sphinx") -> Dict[str, Any]: | |||
app.add_directive('testoutput', TestoutputDirective) | |||
app.add_builder(DocTestBuilder) | |||
# this config value adds to sys.path | |||
app.add_config_value('doctest_show_successes', True, False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app.add_config_value('doctest_show_successes', True, False) | |
app.add_config_value('doctest_show_successes', True, False, (bool,)) |
self._out('\nDocument: %s\n----------%s\n' % | ||
(docname, '-' * len(docname))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._out('\nDocument: %s\n----------%s\n' % | |
(docname, '-' * len(docname))) | |
self._out('\n' | |
f'Document: {docname}\n' | |
f'----------{"-" * len(docname)}\n') |
Thanks @treyhunner! |
Subject: allow hiding verbose doctest successes
Feature
Purpose
For documentation that includes many doctests, seeing both successes and failures can add a lot of noise to the command output.
This change adds a
doctest_show_success
option that, when set toTrue
, will hide doctest successes (only failures will be shown).Relates
Fixes #8654