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. Change-Id: I45bdf565e170793d0342a907628638369d4d0f2f Closes-Bug: #1783638
This commit is contained in:
parent
dc592c68e3
commit
254e0ae839
|
@ -116,8 +116,9 @@ class JSONUtilsTestMixin(object):
|
||||||
self.assertIsInstance(val, six.text_type)
|
self.assertIsInstance(val, six.text_type)
|
||||||
|
|
||||||
def test_dumps_exception_value(self):
|
def test_dumps_exception_value(self):
|
||||||
self.assertEqual('{"a": "ValueError(\'hello\',)"}',
|
self.assertIn(jsonutils.dumps({"a": ValueError("hello")}),
|
||||||
jsonutils.dumps({"a": ValueError("hello")}))
|
['{"a": "ValueError(\'hello\',)"}',
|
||||||
|
'{"a": "ValueError(\'hello\')"}'])
|
||||||
|
|
||||||
|
|
||||||
class JSONUtilsTestJson(JSONUtilsTestMixin, test_base.BaseTestCase):
|
class JSONUtilsTestJson(JSONUtilsTestMixin, test_base.BaseTestCase):
|
||||||
|
@ -407,5 +408,6 @@ class ToPrimitiveTestCase(test_base.BaseTestCase):
|
||||||
self.assertEqual('fallback', ret)
|
self.assertEqual('fallback', ret)
|
||||||
|
|
||||||
def test_exception(self):
|
def test_exception(self):
|
||||||
self.assertEqual("ValueError('an exception',)",
|
self.assertIn(jsonutils.to_primitive(ValueError("an exception")),
|
||||||
jsonutils.to_primitive(ValueError("an exception")))
|
["ValueError('an exception',)",
|
||||||
|
"ValueError('an exception')"])
|
||||||
|
|
Loading…
Reference in New Issue