I have the following test method
def test_fingerprintBadFormat(self):
"""
A C{BadFingerPrintFormat} error is raised when unsupported
formats are requested.
"""
with self.assertRaises(keys.BadFingerPrintFormat) as em:
keys.Key(self.rsaObj).fingerprint('sha256-base')
self.assertEqual('Unsupported fingerprint format: sha256-base',
em.exception.message)
Here is the exception class.
class BadFingerPrintFormat(Exception):
"""
Raises when unsupported fingerprint formats are presented to fingerprint.
"""
this test method works perfectly fine in Python2 but fails in python 3 with the following message
builtins.AttributeError: 'BadFingerPrintFormat' object has no attribute 'message'
How can I test the error message in Python3. I don't like the idea of using asserRaisesRegex as it tests the regex rather than the exception message.