mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
domain override: fix issue #1009.
This commit is contained in:
parent
d5f4e1592a
commit
5521b8da2e
@ -409,7 +409,7 @@ class Sphinx(object):
|
||||
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
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
from StringIO import StringIO
|
||||
|
||||
from sphinx.application import ExtensionError
|
||||
from sphinx.domains import Domain
|
||||
|
||||
from util import *
|
||||
|
||||
@ -69,3 +70,23 @@ def test_extensions():
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user