Improve error info in assertEmpty and assertNotEmpty
When assertEmpty fails, it will print: raise mismatch_error MismatchError: 0 != 5 this is to improve the error info as: raise mismatch_error MismatchError: 0 != 1: list is not empty: [u'1b95a8ea7e124a76bfadf6ce1906aa27'] and when assertNotEmpty fails, it will print: raise self.failureException(msg) AssertionError: 0 not greater than 0 this is to improve the error info as: raise self.failureException(msg) AssertionError: list is empty. Change-Id: Icdf69b596fa135387721c49df164a68799ab9a70
This commit is contained in:
parent
9ca8ef195a
commit
92ade4b8b1
|
@ -643,7 +643,11 @@ class BaseTestCase(testtools.testcase.WithAttributes,
|
|||
cred_provider, networks_client, CONF.compute.fixed_network_name)
|
||||
|
||||
def assertEmpty(self, list, msg=None):
|
||||
if msg is None:
|
||||
msg = "list is not empty: %s" % list
|
||||
self.assertEqual(0, len(list), msg)
|
||||
|
||||
def assertNotEmpty(self, list, msg=None):
|
||||
if msg is None:
|
||||
msg = "list is empty."
|
||||
self.assertGreater(len(list), 0, msg)
|
||||
|
|
Loading…
Reference in New Issue