From 18a208d5d14da2edc2da01b088cca362178daab2 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Mon, 30 Jul 2018 16:45:45 -0400 Subject: [PATCH] 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: Idff8c841fd6c489e887bd72b49e91ef6f0e2d4f3 Closes-Bug: #1784487 --- oslo_vmware/tests/test_exceptions.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/oslo_vmware/tests/test_exceptions.py b/oslo_vmware/tests/test_exceptions.py index 419b7691..2ef24a72 100644 --- a/oslo_vmware/tests/test_exceptions.py +++ b/oslo_vmware/tests/test_exceptions.py @@ -43,7 +43,8 @@ class ExceptionsTest(base.TestCase): def test_vim_fault_exception(self): vfe = exceptions.VimFaultException([ValueError("example")], _("cause")) string = str(vfe) - self.assertEqual("cause\nFaults: [ValueError('example',)]", string) + self.assertIn(string, ["cause\nFaults: [ValueError('example',)]", + "cause\nFaults: [ValueError('example')]"]) def test_vim_fault_exception_with_cause_and_details(self): vfe = exceptions.VimFaultException([ValueError("example")], @@ -51,11 +52,14 @@ class ExceptionsTest(base.TestCase): "FooBar", {'foo': 'bar'}) string = str(vfe) - self.assertEqual("MyMessage\n" - "Cause: FooBar\n" - "Faults: [ValueError('example',)]\n" - "Details: {'foo': 'bar'}", - string) + self.assertIn(string, ["MyMessage\n" + "Cause: FooBar\n" + "Faults: [ValueError('example',)]\n" + "Details: {'foo': 'bar'}", + "MyMessage\n" + "Cause: FooBar\n" + "Faults: [ValueError('example')]\n" + "Details: {'foo': 'bar'}"]) def _create_subclass_exception(self): class VimSubClass(exceptions.VimException):