py37: deal with Exception repr changes

Under Python 3.7, a trailing comma is no longer added to
the init parameters generated by a repr() call:

    >>> repr(Exception('It Works'))
    "Exception('It Works')"

vs

    >>> repr(Exception('It Works'))
    "Exception('It Works',)"

Support pre and post Python 3.7 formats in test cases for
notification middleware.

Change-Id: I30a46ae82f2cc1b529287c049aa5fc6d987e2538
This commit is contained in:
James Page 2018-07-05 06:37:10 -05:00
parent 5626782fac
commit dfb83f4948
1 changed files with 2 additions and 1 deletions

View File

@ -130,7 +130,8 @@ class NotifierMiddlewareTest(utils.BaseTestCase):
exception = call_args[2]['exception']
self.assertIn('middleware.py', exception['traceback'][0])
self.assertIn('It happens!', exception['traceback'][-1])
self.assertEqual("Exception('It happens!',)", exception['value'])
self.assertTrue(exception['value'] in ("Exception('It happens!',)",
"Exception('It happens!')"))
def test_process_request_fail(self):
def notify_error(context, publisher_id, event_type,