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
diff --git a/tempest/test.py b/tempest/test.py
index 970e97c..52994ac 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -643,7 +643,11 @@
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)