Commits

Georg Brandl  committed 4c7414d

#196: Add a warning if an extension module doesn't have a ``setup()`` function.

  • Participants
  • Parent commits 8a36dde

Comments (0)

Files changed (3)

 Release 0.6.2 (in development)
 ==============================
 
+* #196: Add a warning if an extension module doesn't have a
+  ``setup()`` function.
+
 * #158: Allow '..' in template names, and absolute template paths;
   Jinja 2 by default disables both.  
 

File sphinx/application.py

         except ImportError, err:
             raise ExtensionError('Could not import extension %s' % extension,
                                  err)
-        if hasattr(mod, 'setup'):
+        if not hasattr(mod, 'setup'):
+            self.warn('extension %r has no setup() function; is it really '
+                      'a Sphinx extension module?' % extension)
+        else:
             mod.setup(self)
         self._extensions[extension] = mod
 

File tests/test_application.py

         assert app._warncount == old_count + 1
     finally:
         app.cleanup()
+
+
+def test_extensions():
+    status, warnings = StringIO(), StringIO()
+    app = TestApp(status=status, warning=warnings)
+    try:
+        app.setup_extension('shutil')
+        assert warnings.getvalue().startswith("WARNING: extension 'shutil'")
+    finally:
+        app.cleanup()