sphinx/tests/test_errors.py
Jon Dufresne 9d6deec4ca 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'
2018-09-09 11:50:56 -07:00

18 lines
467 B
Python

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