Beautify assertEmpty and assertNotEmpty
Don't use 'list' as a parameter name since this assert can be used for any sequence or collection. Add docstring for both helpers. Change-Id: I747507c3a5d0cf6f84915c8dd9222f4c082cbc04
This commit is contained in:
parent
add0f82828
commit
71c71e9444
|
@ -642,12 +642,24 @@ class BaseTestCase(testtools.testcase.WithAttributes,
|
|||
return fixed_network.get_tenant_network(
|
||||
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 assertEmpty(self, items, msg=None):
|
||||
"""Asserts whether a sequence or collection is empty
|
||||
|
||||
def assertNotEmpty(self, list, msg=None):
|
||||
:param items: sequence or collection to be tested
|
||||
:param msg: message to be passed to the AssertionError
|
||||
:raises AssertionError: when items is not empty
|
||||
"""
|
||||
if msg is None:
|
||||
msg = "list is empty."
|
||||
self.assertGreater(len(list), 0, msg)
|
||||
msg = "sequence or collection is not empty: %s" % items
|
||||
self.assertEqual(0, len(items), msg)
|
||||
|
||||
def assertNotEmpty(self, items, msg=None):
|
||||
"""Asserts whether a sequence or collection is not empty
|
||||
|
||||
:param items: sequence or collection to be tested
|
||||
:param msg: message to be passed to the AssertionError
|
||||
:raises AssertionError: when items is empty
|
||||
"""
|
||||
if msg is None:
|
||||
msg = "sequence or collection is empty."
|
||||
self.assertGreater(len(items), 0, msg)
|
||||
|
|
Loading…
Reference in New Issue