Use more specific asserts in tests
Instead of assertTrue and assertFalse use more specific asserts. They are compatible with Python 2.7[1] and 3.4[2] [1]: https://docs.python.org/2.7/library/unittest.html [2]: https://docs.python.org/3.4/library/unittest.html Change-Id: Id839997ff21c2b1fcf6701f4bc47babe61623817
This commit is contained in:
parent
6e3a8ad6e3
commit
85b392f46c
@ -564,7 +564,7 @@ class TaskTestCase(unittest.TestCase):
|
||||
"deployment_id": deployment_id})
|
||||
results = json.loads(rally("task results"))
|
||||
iterations_completed = len(results[0]["result"])
|
||||
self.assertTrue(iterations_completed < times)
|
||||
self.assertLess(iterations_completed, times)
|
||||
|
||||
def test_start_abort_on_sla_failure_max_seconds_constant(self):
|
||||
times = 100
|
||||
@ -734,7 +734,7 @@ class TaskTestCase(unittest.TestCase):
|
||||
iterations_completed = len(results[0]["result"])
|
||||
# NOTE(msdubov): check that the task is really stopped before
|
||||
# the specified number of iterations
|
||||
self.assertTrue(iterations_completed < RUNNER_TIMES)
|
||||
self.assertLess(iterations_completed, RUNNER_TIMES)
|
||||
self.assertIn("aborted", rally("task status"))
|
||||
report = rally.gen_report_path(extension="html")
|
||||
rally("task report --out %s" % report)
|
||||
|
@ -76,14 +76,16 @@ class QuotasScenarioTestCase(test.ScenarioTestCase):
|
||||
scenario = utils.QuotasScenario(self.context)
|
||||
quotas = scenario._generate_quota_values(max_quota, "nova")
|
||||
for k, v in six.iteritems(quotas):
|
||||
self.assertTrue(-1 <= v <= max_quota)
|
||||
self.assertGreaterEqual(v, -1)
|
||||
self.assertLessEqual(v, max_quota)
|
||||
|
||||
def test__generate_quota_values_cinder(self):
|
||||
max_quota = 1024
|
||||
scenario = utils.QuotasScenario(self.context)
|
||||
quotas = scenario._generate_quota_values(max_quota, "cinder")
|
||||
for k, v in six.iteritems(quotas):
|
||||
self.assertTrue(-1 <= v <= max_quota)
|
||||
self.assertGreaterEqual(v, -1)
|
||||
self.assertLessEqual(v, max_quota)
|
||||
|
||||
def test__generate_quota_values_neutron(self):
|
||||
max_quota = 1024
|
||||
@ -92,7 +94,8 @@ class QuotasScenarioTestCase(test.ScenarioTestCase):
|
||||
for v in six.itervalues(quotas):
|
||||
for v1 in six.itervalues(v):
|
||||
for v2 in six.itervalues(v1):
|
||||
self.assertTrue(-1 <= v2 <= max_quota)
|
||||
self.assertGreaterEqual(v2, -1)
|
||||
self.assertLessEqual(v2, max_quota)
|
||||
|
||||
def test__delete_quotas(self):
|
||||
tenant_id = "fake_tenant"
|
||||
|
Loading…
Reference in New Issue
Block a user