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
This commit is contained in:
parent
01e404f5c2
commit
18a208d5d1
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user