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

Allow doctest_show_success=False option #10938

Merged
merged 2 commits into from Jul 28, 2023

Conversation

treyhunner
Copy link
Contributor

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 to True, will hide doctest successes (only failures will be shown).

Relates

Fixes #8654

@AA-Turner AA-Turner added this to the some future version milestone Apr 29, 2023
@@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
app.add_config_value('doctest_show_successes', True, False)
app.add_config_value('doctest_show_successes', True, False, (bool,))

Comment on lines +458 to +459
self._out('\nDocument: %s\n----------%s\n' %
(docname, '-' * len(docname)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self._out('\nDocument: %s\n----------%s\n' %
(docname, '-' * len(docname)))
self._out('\n'
f'Document: {docname}\n'
f'----------{"-" * len(docname)}\n')

@AA-Turner AA-Turner merged commit aef5445 into sphinx-doc:master Jul 28, 2023
@AA-Turner
Copy link
Member

Thanks @treyhunner!

AA-Turner added a commit that referenced this pull request Aug 10, 2023
@AA-Turner AA-Turner modified the milestones: some future version, 7.2.0 Aug 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sphinx.ext.doctest: Show only failing tests (hide summary for passing)
2 participants