Use assertGreater(len(x), 0) instead of assertTrue(len(x) > 0)

assertGreater provides a nicer error message if it fails.

Change-Id: I5b045042b5991280a5b6a12ccde09fa733a19e26
This commit is contained in:
Cao Xuan Hoang 2016-12-08 15:44:48 +07:00
parent b36d8d9afe
commit d4da920d9b
5 changed files with 7 additions and 7 deletions

View File

@ -78,7 +78,7 @@ class TestProfilers(unittest.TestCase):
p.runctx('import os;os.getcwd();', globals(), locals())
p.snapshot_stats()
self.assertTrue(p.stats is not None)
self.assertTrue(len(p.stats.keys()) > 0)
self.assertGreater(len(p.stats.keys()), 0)
class TestProfileMiddleware(unittest.TestCase):

View File

@ -130,7 +130,7 @@ class TestStoragePolicies(unittest.TestCase):
self.assertEqual(policy_string, get_policy_string(*expected))
def test_defaults(self):
self.assertTrue(len(POLICIES) > 0)
self.assertGreater(len(POLICIES), 0)
# test class functions
default_policy = POLICIES.default

View File

@ -105,7 +105,7 @@ class TestContainerUpdater(unittest.TestCase):
cu.logger = FakeLogger()
cu.run_once()
log_lines = cu.logger.get_lines_for_level('warning')
self.assertTrue(len(log_lines) > 0)
self.assertGreater(len(log_lines), 0)
msg = 'sda1 is not mounted'
self.assertEqual(log_lines[0], msg)
# Ensure that the container_sweep did not run

View File

@ -604,7 +604,7 @@ class TestAuditor(unittest.TestCase):
self.rcache, self.devices)
auditor_worker.audit_all_objects(device_dirs=['sda'])
log_lines = logger.get_lines_for_level('info')
self.assertTrue(len(log_lines) > 0)
self.assertGreater(len(log_lines), 0)
self.assertTrue(log_lines[0].index('ALL - parallel, sda'))
logger = FakeLogger()
@ -613,7 +613,7 @@ class TestAuditor(unittest.TestCase):
zero_byte_only_at_fps=50)
auditor_worker.audit_all_objects(device_dirs=['sda'])
log_lines = logger.get_lines_for_level('info')
self.assertTrue(len(log_lines) > 0)
self.assertGreater(len(log_lines), 0)
self.assertTrue(log_lines[0].index('ZBF - sda'))
def test_object_run_once_no_sda(self):

View File

@ -924,7 +924,7 @@ class DiskFileManagerMixin(BaseDiskFileTestMixin):
mgr = diskfile.DiskFileManager(self.conf, logger)
warnings = logger.get_lines_for_level('warning')
self.assertTrue(len(warnings) > 0)
self.assertGreater(len(warnings), 0)
self.assertTrue('splice()' in warnings[-1])
self.assertFalse(mgr.use_splice)
@ -4671,7 +4671,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
# Despite fs not supporting O_TMPFILE, use_linkat should not change
self.assertTrue(df._use_linkat)
log = df._logger.get_lines_for_level('warning')
self.assertTrue(len(log) > 0)
self.assertGreater(len(log), 0)
self.assertTrue('O_TMPFILE' in log[-1])
@requires_o_tmpfile_support