Merge "Beautify assertEmpty and assertNotEmpty"
This commit is contained in:
commit
1839b8dc9b
@ -642,12 +642,24 @@ class BaseTestCase(testtools.testcase.WithAttributes,
|
|||||||
return fixed_network.get_tenant_network(
|
return fixed_network.get_tenant_network(
|
||||||
cred_provider, networks_client, CONF.compute.fixed_network_name)
|
cred_provider, networks_client, CONF.compute.fixed_network_name)
|
||||||
|
|
||||||
def assertEmpty(self, list, msg=None):
|
def assertEmpty(self, items, msg=None):
|
||||||
if msg is None:
|
"""Asserts whether a sequence or collection is empty
|
||||||
msg = "list is not empty: %s" % list
|
|
||||||
self.assertEqual(0, len(list), msg)
|
|
||||||
|
|
||||||
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:
|
if msg is None:
|
||||||
msg = "list is empty."
|
msg = "sequence or collection is not empty: %s" % items
|
||||||
self.assertGreater(len(list), 0, msg)
|
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…
x
Reference in New Issue
Block a user