Georg Brandl avatar Georg Brandl committed f27729b

Fix #67: Output warnings about failed doctests in the doctest extension
even when running in quiet mode.

Comments (0)

Files changed (3)

 Release 0.5.1 (in development)
 ==============================
 
+* #67: Output warnings about failed doctests in the doctest extension
+  even when running in quiet mode.
+
 * #72: In pngmath, make it possible to give a full path to LaTeX and
   dvipng on Windows.  For that to work, the ``pngmath_latex`` and
   ``pngmath_dvipng`` options are no longer split into command and

sphinx/builder.py

 
         # finish (write static files etc.)
         self.finish()
+        status = self.app.statuscode == 0 and 'succeeded' or 'finished with problems'
         if self.app._warncount:
-            self.info(bold('build succeeded, %s warning%s.' %
-                           (self.app._warncount,
+            self.info(bold('build %s, %s warning%s.' %
+                           (status, self.app._warncount,
                             self.app._warncount != 1 and 's' or '')))
         else:
-            self.info(bold('build succeeded.'))
+            self.info(bold('build %s.' % status))
 
     def write(self, build_docnames, updated_docnames, method='update'):
         if build_docnames is None or build_docnames == ['__all__']:

sphinx/ext/doctest.py

         self.info(text, nonl=True)
         self.outfile.write(text)
 
+    def _warn_out(self, text):
+        self.info(text, nonl=True)
+        if self.app.quiet:
+            self.warn(text)
+        self.outfile.write(text)
+
     def get_target_uri(self, docname, typ=None):
         return ''
 
        self.setup_failures, s(self.setup_failures)))
         self.outfile.close()
 
+        if self.total_failures or self.setup_failures:
+            self.app.statuscode = 1
+
         sys.path[0:0] = self.config.doctest_path
 
     def write(self, build_docnames, updated_docnames, method='update'):
             setup_doctest.globs = ns
             old_f = self.setup_runner.failures
             self.type = 'exec' # the snippet may contain multiple statements
-            self.setup_runner.run(setup_doctest, out=self._out,
+            self.setup_runner.run(setup_doctest, out=self._warn_out,
                                   clear_globs=False)
             if self.setup_runner.failures > old_f:
                 # don't run the group
             # DocTest.__init__ copies the globs namespace, which we don't want
             test.globs = ns
             # also don't clear the globs namespace after running the doctest
-            self.test_runner.run(test, out=self._out, clear_globs=False)
+            self.test_runner.run(test, out=self._warn_out, clear_globs=False)
 
 
 def setup(app):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.