Merge pull request #5401 from jdufresne/message

Fix AttributeError in ExtensionError
This commit is contained in:
Takeshi KOMIYA 2018-09-10 20:40:47 +09:00 committed by GitHub
commit caeaea9028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -55,6 +55,7 @@ class ExtensionError(SphinxError):
def __init__(self, message, orig_exc=None):
# type: (unicode, Exception) -> None
SphinxError.__init__(self, message)
self.message = message
self.orig_exc = orig_exc
def __repr__(self):

17
tests/test_errors.py Normal file
View File

@ -0,0 +1,17 @@
import sys
from sphinx.errors import ExtensionError
def test_extension_error_repr():
exc = ExtensionError("foo")
assert repr(exc) == "ExtensionError('foo')"
def test_extension_error_with_orig_exc_repr():
exc = ExtensionError("foo", Exception("bar"))
if sys.version_info < (3, 7):
expected = "ExtensionError('foo', Exception('bar',))"
else:
expected = "ExtensionError('foo', Exception('bar'))"
assert repr(exc) == expected