From 766c895b5ad70ad45ae1d70e74cc003c45fe33db Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Tue, 20 Sep 2022 16:00:31 -0700 Subject: [PATCH 1/2] Allow doctest_show_success=False option --- sphinx/ext/doctest.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index 8e060907f12..43f62f39564 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -454,8 +454,9 @@ 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: + self._out('\nDocument: %s\n----------%s\n' % + (docname, '-' * len(docname))) for group in groups.values(): self.test_group(group) # Separately count results from setup code @@ -463,12 +464,12 @@ def condition(node: Node) -> bool: 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) self.total_failures += res_f self.total_tries += res_t if self.cleanup_runner.tries: res_f, res_t = self.cleanup_runner.summarize(self._out, - verbose=True) + verbose=self.config.doctest_show_successes) self.cleanup_failures += res_f self.cleanup_tries += res_t @@ -555,6 +556,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) app.add_config_value('doctest_path', [], False) app.add_config_value('doctest_test_doctest_blocks', 'default', False) app.add_config_value('doctest_global_setup', '', False) From 8002b5f1580f674d6f1eb1a886d7db3e1d3ea3be Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Wed, 26 Oct 2022 21:33:06 -0700 Subject: [PATCH 2/2] Fix linting issues --- sphinx/ext/doctest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index 43f62f39564..bb4837f1a9f 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -464,12 +464,13 @@ def condition(node: Node) -> bool: 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=self.config.doctest_show_successes) + res_f, res_t = self.test_runner.summarize( + self._out, verbose=self.config.doctest_show_successes) self.total_failures += res_f self.total_tries += res_t if self.cleanup_runner.tries: - res_f, res_t = self.cleanup_runner.summarize(self._out, - verbose=self.config.doctest_show_successes) + res_f, res_t = self.cleanup_runner.summarize( + self._out, verbose=self.config.doctest_show_successes) self.cleanup_failures += res_f self.cleanup_tries += res_t