Merge "Utilizes assertIsNone and assertIsNotNone"

This commit is contained in:
Jenkins 2014-01-08 06:17:10 +00:00 committed by Gerrit Code Review
commit dff0102633
10 changed files with 17 additions and 17 deletions

View File

@ -395,7 +395,7 @@ class TestCoordinate(test.BaseTestCase):
# Test when the partition to be recorded is the same as the oldest.
self.partition_coordinator._record_oldest(
self.partition_coordinator.oldest, True)
self.assertEqual(self.partition_coordinator.oldest, None)
self.assertIsNone(self.partition_coordinator.oldest)
def test_check_mastership(self):
# Test the method exception condition.

View File

@ -977,7 +977,7 @@ class TestAlarms(FunctionalTest,
def _assert_is_subset(self, expected, actual):
for k, v in expected.iteritems():
self.assertEqual(v, actual.get(k), 'mismatched field: %s' % k)
self.assertTrue(actual['event_id'] is not None)
self.assertIsNotNone(actual['event_id'])
def _assert_in_json(self, expected, actual):
for k, v in expected.iteritems():

View File

@ -101,5 +101,5 @@ class TestLocationMetadata(test.BaseTestCase):
self.INSTANCE_PROPERTIES['image'] = ''
self.instance = FauxInstance(**self.INSTANCE_PROPERTIES)
md = util._get_metadata_from_object(self.instance)
self.assertEqual(md['image_ref'], None)
self.assertEqual(md['image_ref_url'], None)
self.assertIsNone(md['image_ref'])
self.assertIsNone(md['image_ref_url'])

View File

@ -179,7 +179,7 @@ class TestLibvirtInspection(test.BaseTestCase):
vnic2, info2 = interfaces[2]
self.assertEqual(vnic2.name, 'vnet2')
self.assertEqual(vnic2.mac, 'fa:16:3e:96:33:f0')
self.assertEqual(vnic2.fref, None)
self.assertIsNone(vnic2.fref)
self.assertEqual(vnic2.parameters, dict())
self.assertEqual(info2.rx_bytes, 9L)
self.assertEqual(info2.rx_packets, 10L)

View File

@ -92,7 +92,7 @@ NOTIFICATION_DELETE = {"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
class TestNotification(test.BaseTestCase):
def _verify_common_counter(self, c, name, volume):
self.assertFalse(c is None)
self.assertIsNotNone(c)
self.assertEqual(c.name, name)
self.assertEqual(c.resource_id, fake_uuid('c'))
self.assertEqual(c.timestamp, NOW)

View File

@ -185,7 +185,7 @@ class TestSwiftMiddleware(test.BaseTestCase):
self.assertEqual(data.volume, 28)
self.assertEqual(data.resource_metadata['version'], '1.0')
self.assertEqual(data.resource_metadata['container'], 'container')
self.assertEqual(data.resource_metadata['object'], None)
self.assertIsNone(data.resource_metadata['object'])
def test_no_metadata_headers(self):
app = swift_middleware.CeilometerMiddleware(FakeApp(), {})
@ -200,7 +200,7 @@ class TestSwiftMiddleware(test.BaseTestCase):
self.assertEqual(len(http_headers), 0)
self.assertEqual(data.resource_metadata['version'], '1.0')
self.assertEqual(data.resource_metadata['container'], 'container')
self.assertEqual(data.resource_metadata['object'], None)
self.assertIsNone(data.resource_metadata['object'])
def test_metadata_headers(self):
app = swift_middleware.CeilometerMiddleware(FakeApp(), {
@ -219,7 +219,7 @@ class TestSwiftMiddleware(test.BaseTestCase):
self.assertEqual(len(http_headers), 2)
self.assertEqual(data.resource_metadata['version'], '1.0')
self.assertEqual(data.resource_metadata['container'], 'container')
self.assertEqual(data.resource_metadata['object'], None)
self.assertIsNone(data.resource_metadata['object'])
self.assertEqual(data.resource_metadata['http_header_x_var1'],
'value1')
self.assertEqual(data.resource_metadata['http_header_x_var2'],
@ -241,7 +241,7 @@ class TestSwiftMiddleware(test.BaseTestCase):
self.assertEqual(len(http_headers), 0)
self.assertEqual(data.resource_metadata['version'], '1.0')
self.assertEqual(data.resource_metadata['container'], 'container')
self.assertEqual(data.resource_metadata['object'], None)
self.assertIsNone(data.resource_metadata['object'])
def test_bogus_path(self):
app = swift_middleware.CeilometerMiddleware(FakeApp(), {})

View File

@ -71,12 +71,12 @@ class PreciseTimestampTest(test.BaseTestCase):
def test_process_bind_param_store_none_mysql(self):
result = self._type.process_bind_param(None, self._mysql_dialect)
self.assertEqual(result, None)
self.assertIsNone(result)
def test_process_bind_param_store_none_postgres(self):
result = self._type.process_bind_param(None,
self._postgres_dialect)
self.assertEqual(result, None)
self.assertIsNone(result)
def test_process_result_value_datetime_mysql(self):
dec_value = utils.dt_to_decimal(self._date)
@ -92,9 +92,9 @@ class PreciseTimestampTest(test.BaseTestCase):
def test_process_result_value_none_mysql(self):
result = self._type.process_result_value(None,
self._mysql_dialect)
self.assertEqual(result, None)
self.assertIsNone(result)
def test_process_result_value_none_postgres(self):
result = self._type.process_result_value(None,
self._postgres_dialect)
self.assertEqual(result, None)
self.assertIsNone(result)

View File

@ -119,7 +119,7 @@ class BinApiTestCase(base.BaseTestCase):
r, c = self.http.request(url, 'GET')
except socket.error:
time.sleep(.5)
self.assertEqual(self.subp.poll(), None)
self.assertIsNone(self.subp.poll())
else:
return r, c
return (None, None)

View File

@ -83,7 +83,7 @@ class TestUtils(test.BaseTestCase):
self.assertEqual(pairs, expected)
def test_decimal_to_dt_with_none_parameter(self):
self.assertEqual(utils.decimal_to_dt(None), None)
self.assertIsNone(utils.decimal_to_dt(None))
def test_dict_to_kv(self):
data = {'a': 'A',

View File

@ -103,7 +103,7 @@ NOTIFICATION_VOLUME_RESIZE = {
class TestNotifications(test.BaseTestCase):
def _verify_common_sample(self, s, name, notification):
self.assertFalse(s is None)
self.assertIsNotNone(s)
self.assertEqual(s.name, name)
self.assertEqual(s.resource_id, notification['payload']['volume_id'])
self.assertEqual(s.timestamp, notification['timestamp'])