summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Bryant <corey.bryant@canonical.com>2018-07-30 16:45:45 -0400
committerCorey Bryant <corey.bryant@canonical.com>2018-07-30 16:53:54 -0400
commit18a208d5d14da2edc2da01b088cca362178daab2 (patch)
tree547aa6ed69a27c89a14fafabbb46f42a7368bae7
parent01e404f5c24d883f88a7e061214004351d7f41fd (diff)
downloadoslo-vmware-18a208d5d14da2edc2da01b088cca362178daab2.tar.gz
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
-rw-r--r--oslo_vmware/tests/test_exceptions.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/oslo_vmware/tests/test_exceptions.py b/oslo_vmware/tests/test_exceptions.py
index 419b769..2ef24a7 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):