Use booleans to check for empty lists

Changed from checking for empty collections with
len(list) to checking the boolean value of the list
instead

Closes-Bug: #1538518
Change-Id: Ib601a83b8b6e19ab78690f8ca2834e7ef622cb9b
This commit is contained in:
Steve Wilkerson 2016-02-05 13:38:51 -06:00 committed by Boris Pavlovic
parent aa2fdbfc8d
commit efd641caf0
3 changed files with 8 additions and 8 deletions

View File

@ -518,7 +518,7 @@ def timeout_thread(queue):
all_threads = collections.deque()
while True:
if len(all_threads) == 0:
if not all_threads:
timeout = None
else:
thread_ident, deadline = all_threads[0]

View File

@ -185,10 +185,10 @@ def wait_for_status(resource, ready_statuses, failure_statuses=None,
"tuple")
# make all statuses upper case
ready_statuses = set([s.upper() for s in ready_statuses or []])
failure_statuses = set([s.upper() for s in failure_statuses or []])
ready_statuses = set(s.upper() for s in ready_statuses or [])
failure_statuses = set(s.upper() for s in failure_statuses or [])
if len(ready_statuses & failure_statuses) > 0:
if (ready_statuses & failure_statuses):
raise ValueError(
"Can't wait for resource's %s status. Ready and Failure"
"statuses conflict." % resource_repr)

View File

@ -50,20 +50,20 @@ class TitlesTestCase(test.TestCase):
extra_sections = [x for x in actual.keys() if x not in expect.keys()]
msgs = []
if len(missing_sections) > 0:
if missing_sections:
msgs.append("Missing sections: %s" % missing_sections)
if len(extra_sections) > 0:
if extra_sections:
msgs.append("Extra sections: %s" % extra_sections)
for section in expect.keys():
missing_subsections = [x for x in expect[section]
if x not in actual.get(section, {})]
# extra subsections are allowed
if len(missing_subsections) > 0:
if missing_subsections:
msgs.append("Section '%s' is missing subsections: %s"
% (section, missing_subsections))
if len(msgs) > 0:
if msgs:
self.fail("While checking '%s':\n %s"
% (filename, "\n ".join(msgs)))