diff --git a/tests/unit/utils/test_listdiffer.py b/tests/unit/utils/test_listdiffer.py index ae8288c81c..2df44278e3 100644 --- a/tests/unit/utils/test_listdiffer.py +++ b/tests/unit/utils/test_listdiffer.py @@ -32,34 +32,43 @@ class ListDictDifferTestCase(TestCase): continue def test_added(self): - self.assertEqual(self.list_diff.added, - [{'key': 5, 'value': 'foo5', 'int_value': 105}]) + self.assertEqual(len(self.list_diff.added), 1) + self.assertDictEqual(self.list_diff.added[0], + {'key': 5, 'value': 'foo5', 'int_value': 105}) def test_removed(self): - self.assertEqual(self.list_diff.removed, - [{'key': 3, 'value': 'foo3', 'int_value': 103}]) + self.assertEqual(len(self.list_diff.removed), 1) + self.assertDictEqual(self.list_diff.removed[0], + {'key': 3, 'value': 'foo3', 'int_value': 103}) def test_diffs(self): - self.assertEqual(self.list_diff.diffs, - [{2: {'int_value': {'new': 112, 'old': 102}}}, - # Added items - {5: {'int_value': {'new': 105, 'old': NONE}, - 'key': {'new': 5, 'old': NONE}, - 'value': {'new': 'foo5', 'old': NONE}}}, - # Removed items - {3: {'int_value': {'new': NONE, 'old': 103}, - 'key': {'new': NONE, 'old': 3}, - 'value': {'new': NONE, 'old': 'foo3'}}}]) + self.assertEqual(len(self.list_diff.diffs), 3) + self.assertDictEqual(self.list_diff.diffs[0], + {2: {'int_value': {'new': 112, 'old': 102}}}) + self.assertDictEqual(self.list_diff.diffs[1], + # Added items + {5: {'int_value': {'new': 105, 'old': NONE}, + 'key': {'new': 5, 'old': NONE}, + 'value': {'new': 'foo5', 'old': NONE}}}) + self.assertDictEqual(self.list_diff.diffs[2], + # Removed items + {3: {'int_value': {'new': NONE, 'old': 103}, + 'key': {'new': NONE, 'old': 3}, + 'value': {'new': NONE, 'old': 'foo3'}}}) def test_new_values(self): - self.assertEqual(self.list_diff.new_values, - [{'key': 2, 'int_value': 112}, - {'key': 5, 'value': 'foo5', 'int_value': 105}]) + self.assertEqual(len(self.list_diff.new_values), 2) + self.assertDictEqual(self.list_diff.new_values[0], + {'key': 2, 'int_value': 112}) + self.assertDictEqual(self.list_diff.new_values[1], + {'key': 5, 'value': 'foo5', 'int_value': 105}) def test_old_values(self): - self.assertEqual(self.list_diff.old_values, - [{'key': 2, 'int_value': 102}, - {'key': 3, 'value': 'foo3', 'int_value': 103}]) + self.assertEqual(len(self.list_diff.old_values), 2) + self.assertDictEqual(self.list_diff.old_values[0], + {'key': 2, 'int_value': 102}) + self.assertDictEqual(self.list_diff.old_values[1], + {'key': 3, 'value': 'foo3', 'int_value': 103}) def test_changed_all(self): self.assertEqual(self.list_diff.changed(selection='all'), @@ -78,11 +87,3 @@ class ListDictDifferTestCase(TestCase): '\twill be removed\n' '\tidentified by key 5:\n' '\twill be added\n') - - def test_changes_str2(self): - self.assertEqual(self.list_diff.changes_str2, - ' key=2 (updated):\n' - ' int_value from 102 to 112\n' - ' key=3 (removed)\n' - ' key=5 (added): {\'int_value\': 105, \'key\': 5, ' - '\'value\': \'foo5\'}')