Revert "assertItemsEqual() moved to assertCountEqual()"

This reverts commit 3d2617983b.

The change was not quite right because the method six provides needs to
have `self` be passed in as well.  See the docs here:
https://six.readthedocs.io/#unittest-assertions

Reverting for now and we can fix it in smaller chunks later.
This commit is contained in:
Feanil Patel
2019-08-20 15:31:20 -04:00
parent 3d2617983b
commit 73a146fbbe
44 changed files with 111 additions and 132 deletions

View File

@@ -1836,7 +1836,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
with check_mongo_calls(max_find, max_send):
found_orphans = self.store.get_orphans(self.course_locations[self.MONGO_COURSEID].course_key)
six.assertCountEqual(found_orphans, orphan_locations)
self.assertItemsEqual(found_orphans, orphan_locations)
@ddt.data(ModuleStoreEnum.Type.mongo)
def test_get_non_orphan_parents(self, default_ms):

View File

@@ -8,7 +8,6 @@ import copy
import unittest
import ddt
import six
from bson.objectid import ObjectId
from mock import MagicMock, Mock, call
from opaque_keys.edx.locator import CourseLocator
@@ -170,7 +169,7 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin):
self.bulk.update_structure(self.course_key.replace(branch='b'), other_structure)
self.assertConnCalls()
self.bulk._end_bulk_operation(self.course_key)
six.assertCountEqual(
self.assertItemsEqual(
[
call.insert_structure(self.structure, self.course_key),
call.insert_structure(other_structure, self.course_key)
@@ -206,7 +205,7 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin):
self.bulk.update_definition(self.course_key.replace(branch='b'), other_definition)
self.bulk.insert_course_index(self.course_key, {'versions': {'a': self.definition['_id'], 'b': other_definition['_id']}})
self.bulk._end_bulk_operation(self.course_key)
six.assertCountEqual(
self.assertItemsEqual(
[
call.insert_definition(self.definition, self.course_key),
call.insert_definition(other_definition, self.course_key),
@@ -237,7 +236,7 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin):
self.bulk.update_definition(self.course_key.replace(branch='b'), other_definition)
self.assertConnCalls()
self.bulk._end_bulk_operation(self.course_key)
six.assertCountEqual(
self.assertItemsEqual(
[
call.insert_definition(self.definition, self.course_key),
call.insert_definition(other_definition, self.course_key)
@@ -273,7 +272,7 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin):
self.bulk.update_structure(self.course_key.replace(branch='b'), other_structure)
self.bulk.insert_course_index(self.course_key, {'versions': {'a': self.structure['_id'], 'b': other_structure['_id']}})
self.bulk._end_bulk_operation(self.course_key)
six.assertCountEqual(
self.assertItemsEqual(
[
call.insert_structure(self.structure, self.course_key),
call.insert_structure(other_structure, self.course_key),
@@ -393,7 +392,7 @@ class TestBulkWriteMixinFindMethods(TestBulkWriteMixin):
expected = matching + db_indexes
self.conn.find_matching_course_indexes.return_value = db_indexes
result = self.bulk.find_matching_course_indexes(branch, search_targets)
six.assertCountEqual(result, expected)
self.assertItemsEqual(result, expected)
for item in unmatching:
self.assertNotIn(item, result)
@@ -581,7 +580,7 @@ class TestBulkWriteMixinFindMethods(TestBulkWriteMixin):
self.conn.find_ancestor_structures.return_value = db_match + db_unmatch
results = self.bulk.find_ancestor_structures(original_version, block_id)
self.conn.find_ancestor_structures.assert_called_once_with(original_version, block_id)
six.assertCountEqual(active_match + db_match, results)
self.assertItemsEqual(active_match + db_match, results)
@ddt.ddt

View File

@@ -395,7 +395,7 @@ class CourseComparisonTest(TestCase):
}
# Split Mongo and Old-Mongo disagree about what the block_id of courses is, so skip those in
# this comparison
six.assertCountEqual(
self.assertItemsEqual(
[map_key(item.location) for item in expected_items if item.scope_ids.block_type != 'course'],
[key for key in actual_item_map.keys() if key[0] != 'course'],
)

View File

@@ -863,7 +863,7 @@ class ProblemBlockTest(unittest.TestCase):
self.assertEqual(xqueue_interface._http_post.call_count, 1)
_, kwargs = xqueue_interface._http_post.call_args # pylint: disable=unpacking-non-sequence
six.assertCountEqual(fpaths, list(kwargs['files'].keys()))
self.assertItemsEqual(fpaths, list(kwargs['files'].keys()))
for fpath, fileobj in six.iteritems(kwargs['files']):
self.assertEqual(fpath, fileobj.name)
@@ -896,7 +896,7 @@ class ProblemBlockTest(unittest.TestCase):
self.assertEqual(xqueue_interface._http_post.call_count, 1)
_, kwargs = xqueue_interface._http_post.call_args # pylint: disable=unpacking-non-sequence
six.assertCountEqual(fnames, list(kwargs['files'].keys()))
self.assertItemsEqual(fnames, list(kwargs['files'].keys()))
for fpath, fileobj in six.iteritems(kwargs['files']):
self.assertEqual(fpath, fileobj.name)

View File

@@ -14,7 +14,6 @@ import ddt
import lxml.etree
import mock
import pytz
import six
from django.utils.translation import ugettext_lazy
from fs.osfs import OSFS
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
@@ -137,7 +136,7 @@ class RoundTripTestCase(unittest.TestCase):
course_id = initial_course.id
print("Checking key equality")
six.assertCountEqual(
self.assertItemsEqual(
list(initial_import.modules[course_id].keys()),
list(second_import.modules[course_id].keys())
)