Franck Michea avatar Franck Michea committed d4718ee

domain override: fix issue #1009.

Comments (0)

Files changed (2)

sphinx/application.py

         if domain.name not in self.domains:
             raise ExtensionError('domain %s not yet registered' % domain.name)
         if not issubclass(domain, self.domains[domain.name]):
-            raise ExtensionError('new domain not a subclass of registered '
+            raise ExtensionError('new domain not a subclass of registered %s '
                                  'domain' % domain.name)
         self.domains[domain.name] = domain
 

tests/test_application.py

 from StringIO import StringIO
 
 from sphinx.application import ExtensionError
+from sphinx.domains import Domain
 
 from util import *
 
         assert warnings.getvalue().startswith("WARNING: extension 'shutil'")
     finally:
         app.cleanup()
+
+def test_domain_override():
+    class A(Domain):
+        name = 'foo'
+    class B(A):
+        name = 'foo'
+    class C(Domain):
+        name = 'foo'
+    status, warnings = StringIO(), StringIO()
+    app = TestApp(status=status, warning=warnings)
+    try:
+        # No domain know named foo.
+        raises_msg(ExtensionError, 'domain foo not yet registered',
+                   app.override_domain, A)
+        assert app.add_domain(A) is None
+        assert app.override_domain(B) is None
+        raises_msg(ExtensionError, 'new domain not a subclass of registered '
+                   'foo domain', app.override_domain, C)
+    finally:
+        app.cleanup()
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.