Commits

Georg Brandl  committed f5396e0 Merge

Merge in #67 bugfix.

  • Participants
  • Parent commits 91833fd, f27729b

Comments (0)

Files changed (4)

 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

File sphinx/builder.py

File contents unchanged.

File sphinx/builders/__init__.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__']:

File 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
                 test = parser.get_doctest(code[0].code, {},
                                           group.name, filename, code[0].lineno)
                 if not test.examples:
-                    self._out('WARNING: no examples in doctest block at '
-                              + filename + ', line %s\n' % code[0].lineno)
                     continue
                 for example in test.examples:
                     # apply directive's comparison options
             # 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):