Use assertEqual() instead of assertDictEqual()
OpenStack now has dropped support for python 2.6 and lower. So we don't need to define an assertDictEqual() for python lower than 2.7. Further, assertEqual() in testtools is able to handle dicts comparation, just the same as assertDictEqual() in unittest2. So we do't need to call assertDictEqual() for dicts any more. Please also refer to: https://review.openstack.org/#/c/347097/ Change-Id: Ieaf211617c38aa0f9a38625b1009c36bd6a16fba
This commit is contained in:
@@ -563,7 +563,7 @@ class SessionAuthTests(utils.TestCase):
|
||||
auth = AuthPlugin()
|
||||
sess = client_session.Session(auth=auth)
|
||||
resp = sess.get(self.TEST_URL)
|
||||
self.assertDictEqual(resp.json(), self.TEST_JSON)
|
||||
self.assertEqual(resp.json(), self.TEST_JSON)
|
||||
|
||||
self.assertRequestHeaderEqual('X-Auth-Token', AuthPlugin.TEST_TOKEN)
|
||||
|
||||
@@ -573,7 +573,7 @@ class SessionAuthTests(utils.TestCase):
|
||||
auth = AuthPlugin()
|
||||
sess = client_session.Session(auth=auth)
|
||||
resp = sess.get(self.TEST_URL, authenticated=False)
|
||||
self.assertDictEqual(resp.json(), self.TEST_JSON)
|
||||
self.assertEqual(resp.json(), self.TEST_JSON)
|
||||
|
||||
self.assertRequestHeaderEqual('X-Auth-Token', None)
|
||||
|
||||
|
@@ -110,24 +110,6 @@ class TestCase(testtools.TestCase):
|
||||
self.assertEqual(headers.get(name), val)
|
||||
|
||||
|
||||
if tuple(sys.version_info)[0:2] < (2, 7):
|
||||
|
||||
def assertDictEqual(self, d1, d2, msg=None):
|
||||
# Simple version taken from 2.7
|
||||
self.assertIsInstance(d1, dict,
|
||||
'First argument is not a dictionary')
|
||||
self.assertIsInstance(d2, dict,
|
||||
'Second argument is not a dictionary')
|
||||
if d1 != d2:
|
||||
if msg:
|
||||
self.fail(msg)
|
||||
else:
|
||||
standardMsg = '%r != %r' % (d1, d2)
|
||||
self.fail(standardMsg)
|
||||
|
||||
TestCase.assertDictEqual = assertDictEqual
|
||||
|
||||
|
||||
def test_response(**kwargs):
|
||||
r = requests.Request(method='GET', url='http://localhost:5000').prepare()
|
||||
return requests_mock.create_response(r, **kwargs)
|
||||
|
@@ -164,7 +164,7 @@ class ProjectTests(utils.ClientTestCase, utils.CrudTests):
|
||||
|
||||
returned = self.manager.get(ref['id'], subtree_as_ids=True)
|
||||
self.assertQueryStringIs('subtree_as_ids')
|
||||
self.assertDictEqual(ref['subtree'], returned.subtree)
|
||||
self.assertEqual(ref['subtree'], returned.subtree)
|
||||
|
||||
def test_get_with_parents_as_ids(self):
|
||||
projects = self._create_projects_hierarchy()
|
||||
@@ -187,7 +187,7 @@ class ProjectTests(utils.ClientTestCase, utils.CrudTests):
|
||||
|
||||
returned = self.manager.get(ref['id'], parents_as_ids=True)
|
||||
self.assertQueryStringIs('parents_as_ids')
|
||||
self.assertDictEqual(ref['parents'], returned.parents)
|
||||
self.assertEqual(ref['parents'], returned.parents)
|
||||
|
||||
def test_get_with_parents_as_ids_and_subtree_as_ids(self):
|
||||
ref = self.new_ref()
|
||||
@@ -209,8 +209,8 @@ class ProjectTests(utils.ClientTestCase, utils.CrudTests):
|
||||
parents_as_ids=True,
|
||||
subtree_as_ids=True)
|
||||
self.assertQueryStringIs('subtree_as_ids&parents_as_ids')
|
||||
self.assertDictEqual(ref['parents'], returned.parents)
|
||||
self.assertDictEqual(ref['subtree'], returned.subtree)
|
||||
self.assertEqual(ref['parents'], returned.parents)
|
||||
self.assertEqual(ref['subtree'], returned.subtree)
|
||||
|
||||
def test_get_with_subtree_as_list(self):
|
||||
projects = self._create_projects_hierarchy()
|
||||
|
Reference in New Issue
Block a user