diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-09-08 10:20:15 -0700 |
---|---|---|
committer | Jon Dufresne <jon.dufresne@gmail.com> | 2018-09-09 11:50:56 -0700 |
commit | 9d6deec4ca2f95460ef62b54b7b42f589ef3351e (patch) | |
tree | c867faa3a43e6241f11ca8533096244ddd337d1b /tests/test_errors.py | |
parent | cf707ac46f0cdfdd437b60744b7dc54362e4c656 (diff) | |
download | sphinx-git-9d6deec4ca2f95460ef62b54b7b42f589ef3351e.tar.gz |
Fix AttributeError in ExtensionError
In Python 3, the attribute BaseException.message doesn't exist.
$ python3
>>> from sphinx.errors import ExtensionError
>>> e = ExtensionError('foo')
>>> repr(e)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sphinx/sphinx/errors.py", line 65, in __repr__
return '%s(%r)' % (self.__class__.__name__, self.message)
AttributeError: 'ExtensionError' object has no attribute 'message'
Diffstat (limited to 'tests/test_errors.py')
-rw-r--r-- | tests/test_errors.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_errors.py b/tests/test_errors.py new file mode 100644 index 000000000..c8cf4b05d --- /dev/null +++ b/tests/test_errors.py @@ -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 |