From 7a204383d5ced794035c917cbd7ff8af17299c9a Mon Sep 17 00:00:00 2001 From: Luong Anh Tuan Date: Mon, 29 Aug 2016 12:40:07 +0700 Subject: [PATCH] Using assertIsNone() instead of assertEqual(None) Following OpenStack Style Guidelines[1]: http://docs.openstack.org/developer/hacking/#unit-tests-and-assertraises [H203] Unit test assertions tend to give better messages for more specific assertions. As a result, assertIsNone(...) is preferred over assertEqual(None, ...) and assertIs(..,None) Change-Id: I8881abed6e7962d1516323725e194937bce1346f --- nova/tests/unit/api/openstack/test_wsgi.py | 4 ++-- nova/tests/unit/objects/test_floating_ip.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/tests/unit/api/openstack/test_wsgi.py b/nova/tests/unit/api/openstack/test_wsgi.py index 4e954725b1d7..56f54a3c0152 100644 --- a/nova/tests/unit/api/openstack/test_wsgi.py +++ b/nova/tests/unit/api/openstack/test_wsgi.py @@ -159,7 +159,7 @@ class RequestTest(MicroversionedTest): request = wsgi.Request.blank('/') accepted = 'nb-no' request.headers = {'Accept-Language': accepted} - self.assertIs(request.best_match_language(), None) + self.assertIsNone(request.best_match_language()) def test_no_lang_header(self): self.stubs.Set(i18n, 'get_available_languages', @@ -168,7 +168,7 @@ class RequestTest(MicroversionedTest): request = wsgi.Request.blank('/') accepted = '' request.headers = {'Accept-Language': accepted} - self.assertIs(request.best_match_language(), None) + self.assertIsNone(request.best_match_language()) def test_api_version_request_header_none(self): request = wsgi.Request.blank('/') diff --git a/nova/tests/unit/objects/test_floating_ip.py b/nova/tests/unit/objects/test_floating_ip.py index 44007775703e..354e1eb0acf2 100644 --- a/nova/tests/unit/objects/test_floating_ip.py +++ b/nova/tests/unit/objects/test_floating_ip.py @@ -233,7 +233,7 @@ class _TestFloatingIPObject(object): ips = [objects.FloatingIPList.make_ip_info('1.1.1.1', 'pool', 'eth0'), objects.FloatingIPList.make_ip_info('1.1.1.2', 'loop', 'eth1')] result = objects.FloatingIPList.create(None, ips) - self.assertIs(result, None) + self.assertIsNone(result) result = objects.FloatingIPList.create(None, ips, want_result=True) self.assertEqual('1.1.1.1', str(result[0].address)) self.assertEqual('1.1.1.2', str(result[1].address))