Use assertItemsEqual() instead of assertListEqual()
assertListEqual() is order sensitive. So we need to sort the lists before we compare them. Use assertItemsEqual() instead is better. Change-Id: I9eaa98716c7401f5b099b007438acc916dae619b
This commit is contained in:
		| @@ -91,11 +91,7 @@ class TestMultiKeyValueAction(utils.TestCase): | ||||
|             {'req1': 'aaa', 'req2': 'bbb'}, | ||||
|             {'req1': '', 'req2': ''}, | ||||
|         ] | ||||
|         # Need to sort the lists before comparing them | ||||
|         key = lambda x: x['req1'] | ||||
|         expect.sort(key=key) | ||||
|         actual.sort(key=key) | ||||
|         self.assertListEqual(expect, actual) | ||||
|         self.assertItemsEqual(expect, actual) | ||||
|  | ||||
|     def test_empty_required_optional(self): | ||||
|         self.parser.add_argument( | ||||
| @@ -119,11 +115,7 @@ class TestMultiKeyValueAction(utils.TestCase): | ||||
|             {'req1': 'aaa', 'req2': 'bbb'}, | ||||
|             {'req1': '', 'req2': ''}, | ||||
|         ] | ||||
|         # Need to sort the lists before comparing them | ||||
|         key = lambda x: x['req1'] | ||||
|         expect.sort(key=key) | ||||
|         actual.sort(key=key) | ||||
|         self.assertListEqual(expect, actual) | ||||
|         self.assertItemsEqual(expect, actual) | ||||
|  | ||||
|     def test_error_values_with_comma(self): | ||||
|         self.assertRaises( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tang Chen
					Tang Chen