I would turn on the doctest.IGNORE_EXCEPTION_DETAIL
directive, like this:
>>> spam_function() # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last)
...
SpamException: 'lovely spam'
But note that IGNORE_EXCEPTION_DETAIL
doesn't work for plain exception objects (with no associated arguments). In particular, the following example isn't portable to Python 3, because there's nothing following the exception name:
>>> spam_function() # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last)
...
SpamException