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

@@ -842,7 +842,7 @@ class TestGetProgramsByType(CacheIsolationTestCase):
def test_get_masters_programs(self):
expected_programs = [self.masters_program_1, self.masters_program_2]
six.assertCountEqual(expected_programs, get_programs_by_type(self.site, 'masters'))
self.assertItemsEqual(expected_programs, get_programs_by_type(self.site, 'masters'))
def test_get_bachelors_programs(self):
expected_programs = [self.bachelors_program]

View File

@@ -422,7 +422,7 @@ class TestModuleStoreSerializer(TestDumpToNeo4jCommandBase):
# 2 nodes and no relationships from the second
self.assertEqual(len(mock_graph.nodes), 11)
six.assertCountEqual(submitted, self.course_strings)
self.assertItemsEqual(submitted, self.course_strings)
@mock.patch('openedx.core.djangoapps.coursegraph.tasks.NodeSelector')
@mock.patch('openedx.core.djangoapps.coursegraph.tasks.authenticate_and_create_graph')
@@ -445,7 +445,7 @@ class TestModuleStoreSerializer(TestDumpToNeo4jCommandBase):
number_rollbacks=2,
)
six.assertCountEqual(submitted, self.course_strings)
self.assertItemsEqual(submitted, self.course_strings)
@mock.patch('openedx.core.djangoapps.coursegraph.tasks.NodeSelector')
@mock.patch('openedx.core.djangoapps.coursegraph.tasks.authenticate_and_create_graph')

View File

@@ -363,7 +363,7 @@ class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, Ente
response = self.client.get(reverse('courseenrollments'), {'user': self.user.username}, **kwargs)
self.assertEqual(response.status_code, status.HTTP_200_OK)
data = json.loads(response.content.decode('utf-8'))
six.assertCountEqual(
self.assertItemsEqual(
[(datum['course_details']['course_id'], datum['course_details']['course_name']) for datum in data],
[(six.text_type(course.id), course.display_name_with_default) for course in courses]
)
@@ -1680,4 +1680,4 @@ class CourseEnrollmentsApiListTest(APITestCase, ModuleStoreTestCase):
content = self._assert_list_of_enrollments(query_params, status.HTTP_200_OK)
results = content['results']
six.assertCountEqual(results, expected_results)
self.assertItemsEqual(results, expected_results)

View File

@@ -8,7 +8,6 @@ import itertools
import ddt
import mock
import six
from django.conf import settings
from django.contrib.sessions.middleware import SessionMiddleware
from django.http import HttpResponse
@@ -150,7 +149,7 @@ class TestUserPreferenceMiddleware(CacheIsolationTestCase):
accept_lang_out = parse_accept_lang_header(accept_lang_out)
if accept_lang_out and accept_lang_result:
six.assertCountEqual(accept_lang_result, accept_lang_out)
self.assertItemsEqual(accept_lang_result, accept_lang_out)
else:
self.assertEqual(accept_lang_result, accept_lang_out)

View File

@@ -674,7 +674,7 @@ class TestProgramProgressMeter(TestCase):
self._create_certificates(unknown['key'], status='unknown')
meter = ProgramProgressMeter(self.site, self.user)
six.assertCountEqual(
self.assertItemsEqual(
meter.completed_course_runs,
[
{'course_run_id': downloadable['key'], 'type': CourseMode.VERIFIED},

View File

@@ -7,7 +7,6 @@ import logging
from unittest import skipUnless
import ddt
import six
from django.conf import settings
from edx_ace import Message
from edx_ace.utils.date import serialize
@@ -87,7 +86,7 @@ class TestUpgradeReminder(ScheduleSendEmailTestMixin, CacheIsolationTestCase):
messages = [Message.from_string(m) for m in sent_messages]
self.assertEqual(len(messages), 1)
message = messages[0]
six.assertCountEqual(
self.assertItemsEqual(
message.context['course_ids'],
[str(schedules[i].enrollment.course.id) for i in (1, 2, 4)]
)

View File

@@ -3,7 +3,6 @@ Tests for helper function provided by site_configuration app.
"""
from __future__ import absolute_import
import six
from django.test import TestCase
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
@@ -82,7 +81,7 @@ class TestHelpers(TestCase):
Test that get_dict returns correct value for any given key.
"""
# Make sure entry is saved and retrieved correctly
six.assertCountEqual(
self.assertItemsEqual(
configuration_helpers.get_dict("REGISTRATION_EXTRA_FIELDS"),
test_config['REGISTRATION_EXTRA_FIELDS'],
)
@@ -92,7 +91,7 @@ class TestHelpers(TestCase):
expected.update(test_config['REGISTRATION_EXTRA_FIELDS'])
# Test that the default value is returned if the value for the given key is not found in the configuration
six.assertCountEqual(
self.assertItemsEqual(
configuration_helpers.get_dict("REGISTRATION_EXTRA_FIELDS", default),
expected,
)
@@ -135,7 +134,7 @@ class TestHelpers(TestCase):
test_config['css_overrides_file']
)
six.assertCountEqual(
self.assertItemsEqual(
configuration_helpers.get_value_for_org(test_org, "REGISTRATION_EXTRA_FIELDS"),
test_config['REGISTRATION_EXTRA_FIELDS']
)
@@ -178,7 +177,7 @@ class TestHelpers(TestCase):
"""
test_orgs = [test_config['course_org_filter']]
with with_site_configuration_context(configuration=test_config):
six.assertCountEqual(
self.assertItemsEqual(
list(configuration_helpers.get_all_orgs()),
test_orgs,
)
@@ -186,7 +185,7 @@ class TestHelpers(TestCase):
@with_site_configuration(configuration=test_config_multi_org)
def test_get_current_site_orgs(self):
test_orgs = test_config_multi_org['course_org_filter']
six.assertCountEqual(
self.assertItemsEqual(
list(configuration_helpers.get_current_site_orgs()),
test_orgs
)

View File

@@ -3,7 +3,6 @@ Tests for Management commands of comprehensive theming.
"""
from __future__ import absolute_import
import six
from django.core.management import CommandError, call_command
from django.test import TestCase
@@ -45,12 +44,12 @@ class TestUpdateAssets(TestCase):
"""
# make sure compile_sass picks all themes when called with 'themes=all' option
parsed_args = Command.parse_arguments(themes=["all"])
six.assertCountEqual(parsed_args[2], get_themes())
self.assertItemsEqual(parsed_args[2], get_themes())
# make sure compile_sass picks no themes when called with 'themes=no' option
parsed_args = Command.parse_arguments(themes=["no"])
six.assertCountEqual(parsed_args[2], [])
self.assertItemsEqual(parsed_args[2], [])
# make sure compile_sass picks only specified themes
parsed_args = Command.parse_arguments(themes=["test-theme"])
six.assertCountEqual(parsed_args[2], [theme for theme in get_themes() if theme.theme_dir_name == "test-theme"])
self.assertItemsEqual(parsed_args[2], [theme for theme in get_themes() if theme.theme_dir_name == "test-theme"])

View File

@@ -3,7 +3,6 @@ Test helpers for Comprehensive Theming.
"""
from __future__ import absolute_import
import six
from django.conf import settings
from django.test import TestCase, override_settings
from edx_django_utils.cache import RequestCache
@@ -39,7 +38,7 @@ class TestHelpers(TestCase):
Theme('test-theme', 'test-theme', get_theme_base_dir('test-theme'), settings.PROJECT_ROOT),
]
actual_themes = get_themes()
six.assertCountEqual(expected_themes, actual_themes)
self.assertItemsEqual(expected_themes, actual_themes)
@override_settings(COMPREHENSIVE_THEME_DIRS=[settings.TEST_THEME.dirname()])
def test_get_themes_2(self):
@@ -50,7 +49,7 @@ class TestHelpers(TestCase):
Theme('test-theme', 'test-theme', get_theme_base_dir('test-theme'), settings.PROJECT_ROOT),
]
actual_themes = get_themes()
six.assertCountEqual(expected_themes, actual_themes)
self.assertItemsEqual(expected_themes, actual_themes)
def test_get_value_returns_override(self):
"""

View File

@@ -11,7 +11,6 @@ import unittest
import ddt
import mock
import pytz
import six
from consent.models import DataSharingConsent
from django.conf import settings
from django.contrib.auth.models import User
@@ -566,7 +565,7 @@ class TestPartnerReportingList(ModuleStoreTestCase):
for returned_user in returned_users:
returned_user['orgs'].sort()
six.assertCountEqual(returned_users, expected_users)
self.assertCountEqual(returned_users, expected_users)
def test_success(self):
"""
@@ -662,7 +661,7 @@ class TestAccountRetirementList(RetirementTestCase):
del retirement['created']
del retirement['modified']
six.assertCountEqual(response_data, expected_data)
self.assertItemsEqual(response_data, expected_data)
def test_empty(self):
"""
@@ -835,7 +834,7 @@ class TestAccountRetirementsByStatusAndDate(RetirementTestCase):
except KeyError:
pass
six.assertCountEqual(response_data, expected_data)
self.assertItemsEqual(response_data, expected_data)
def test_empty(self):
"""

View File

@@ -12,7 +12,6 @@ from copy import deepcopy
import ddt
import mock
import pytz
import six
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test.testcases import TransactionTestCase
@@ -791,7 +790,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase):
# than django model id.
for proficiencies in ([{"code": "en"}, {"code": "fr"}, {"code": "es"}], [{"code": "fr"}], [{"code": "aa"}], []):
response = self.send_patch(client, {"language_proficiencies": proficiencies})
six.assertCountEqual(response.data["language_proficiencies"], proficiencies)
self.assertItemsEqual(response.data["language_proficiencies"], proficiencies)
@ddt.data(
(

View File

@@ -19,7 +19,7 @@ from django.test.utils import override_settings
from django.urls import reverse
from opaque_keys.edx.keys import CourseKey
from pytz import UTC, common_timezones_set
from six import text_type, assertCountEqual
from six import text_type
from six.moves import range
from social_django.models import Partial, UserSocialAuth
@@ -93,8 +93,8 @@ class UserAPITestCase(ApiTestCase):
def assertUserIsValid(self, user):
"""Assert that the given user result is valid"""
assertCountEqual(list(user.keys()), ["email", "id", "name", "username", "preferences", "url"])
assertCountEqual(
self.assertItemsEqual(list(user.keys()), ["email", "id", "name", "username", "preferences", "url"])
self.assertItemsEqual(
list(user["preferences"].items()),
[(pref.key, pref.value) for pref in self.prefs if pref.user.id == user["id"]]
)
@@ -104,7 +104,7 @@ class UserAPITestCase(ApiTestCase):
"""
Assert that the given preference is acknowledged by the system
"""
assertCountEqual(list(pref.keys()), ["user", "key", "value", "url"])
self.assertItemsEqual(list(pref.keys()), ["user", "key", "value", "url"])
self.assertSelfReferential(pref)
self.assertUserIsValid(pref["user"])