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:
parent
a1e740a0b4
commit
9ae313c82a
@ -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)))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user