Merge pull request #22643 from edx/feanil/2to3_asserts
Run `2to3 -f asserts . -w` on edx-platform.
This commit is contained in:
@@ -248,13 +248,13 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
# Make the course cohorted...
|
||||
config_course_cohorts(course, is_cohorted=True)
|
||||
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
cohorts.get_cohort(user, course.id).id,
|
||||
cohort.id,
|
||||
"user should be assigned to the correct cohort"
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
cohorts.get_cohort(other_user, course.id).id,
|
||||
cohorts.get_cohort_by_name(course.id, cohorts.DEFAULT_COHORT_NAME).id,
|
||||
"other_user should be assigned to the default cohort"
|
||||
@@ -272,14 +272,14 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
|
||||
# Add email address to the cohort
|
||||
(user, previous_cohort, prereg) = cohorts.add_user_to_cohort(cohort, "email@example.com")
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
(user, previous_cohort, prereg),
|
||||
(None, None, True)
|
||||
)
|
||||
|
||||
# Create user with this email address
|
||||
user = UserFactory(username="test", email="email@example.com")
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
cohorts.get_cohort(user, course.id).id,
|
||||
cohort.id,
|
||||
"User should be assigned to the right cohort"
|
||||
@@ -298,21 +298,21 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
|
||||
# Add email address to the first cohort
|
||||
(user, previous_cohort, prereg) = cohorts.add_user_to_cohort(cohort, "email@example.com")
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
(user, previous_cohort, prereg),
|
||||
(None, None, True)
|
||||
)
|
||||
|
||||
# Add email address to the second cohort
|
||||
(user, previous_cohort, prereg) = cohorts.add_user_to_cohort(cohort2, "email@example.com")
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
(user, previous_cohort, prereg),
|
||||
(None, None, True)
|
||||
)
|
||||
|
||||
# Create user with this email address
|
||||
user = UserFactory(username="test", email="email@example.com")
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
cohorts.get_cohort(user, course.id).id,
|
||||
cohort2.id,
|
||||
"User should be assigned to the right cohort"
|
||||
@@ -357,7 +357,7 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
self.assertIsNone(cohorts.get_cohort(user, course.id, assign=False))
|
||||
|
||||
# get_cohort should return a group for user
|
||||
self.assertEquals(cohorts.get_cohort(user, course.id).name, "AutoGroup")
|
||||
self.assertEqual(cohorts.get_cohort(user, course.id).name, "AutoGroup")
|
||||
|
||||
def test_cohorting_with_auto_cohorts(self):
|
||||
"""
|
||||
@@ -379,9 +379,9 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
auto_cohorts=["AutoGroup"]
|
||||
)
|
||||
|
||||
self.assertEquals(cohorts.get_cohort(user1, course.id).id, cohort.id, "user1 should stay put")
|
||||
self.assertEqual(cohorts.get_cohort(user1, course.id).id, cohort.id, "user1 should stay put")
|
||||
|
||||
self.assertEquals(cohorts.get_cohort(user2, course.id).name, "AutoGroup", "user2 should be auto-cohorted")
|
||||
self.assertEqual(cohorts.get_cohort(user2, course.id).name, "AutoGroup", "user2 should be auto-cohorted")
|
||||
|
||||
def test_anonymous_user_cohort(self):
|
||||
"""
|
||||
@@ -416,7 +416,7 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
auto_cohorts=["AutoGroup"]
|
||||
)
|
||||
|
||||
self.assertEquals(cohorts.get_cohort(user1, course.id).name, "AutoGroup", "user1 should be auto-cohorted")
|
||||
self.assertEqual(cohorts.get_cohort(user1, course.id).name, "AutoGroup", "user1 should be auto-cohorted")
|
||||
|
||||
# Now set the auto_cohort_group to something different
|
||||
# This will have no effect on lms side as we are already done with migrations
|
||||
@@ -426,11 +426,11 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
auto_cohort_groups=["OtherGroup"]
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
cohorts.get_cohort(user2, course.id).name, "AutoGroup", "user2 should be assigned to AutoGroups"
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
cohorts.get_cohort(user1, course.id).name, "AutoGroup", "user1 should still be in originally placed cohort"
|
||||
)
|
||||
|
||||
@@ -454,7 +454,7 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
auto_cohorts=[]
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
cohorts.get_cohort(user1, course.id).id,
|
||||
cohorts.get_cohort_by_name(course.id, cohorts.DEFAULT_COHORT_NAME).id,
|
||||
"No groups->default cohort for user1"
|
||||
@@ -468,13 +468,13 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
auto_cohort_groups=["AutoGroup"]
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
cohorts.get_cohort(user1, course.id).name,
|
||||
cohorts.get_cohort_by_name(course.id, cohorts.DEFAULT_COHORT_NAME).name,
|
||||
"user1 should still be in the default cohort"
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
cohorts.get_cohort(user2, course.id).id,
|
||||
cohorts.get_cohort_by_name(course.id, cohorts.DEFAULT_COHORT_NAME).id,
|
||||
"No groups->default cohort for user2"
|
||||
|
||||
@@ -229,7 +229,7 @@ class TestCohortPartitionScheme(ModuleStoreTestCase):
|
||||
with patch('openedx.core.djangoapps.course_groups.partition_scheme.log') as mock_log:
|
||||
self.assert_student_in_group(None, new_user_partition)
|
||||
self.assertTrue(mock_log.warn.called)
|
||||
self.assertRegexpMatches(mock_log.warn.call_args[0][0], 'group not found')
|
||||
self.assertRegex(mock_log.warn.call_args[0][0], 'group not found')
|
||||
|
||||
def test_missing_partition(self):
|
||||
"""
|
||||
@@ -254,7 +254,7 @@ class TestCohortPartitionScheme(ModuleStoreTestCase):
|
||||
with patch('openedx.core.djangoapps.course_groups.partition_scheme.log') as mock_log:
|
||||
self.assert_student_in_group(None, new_user_partition)
|
||||
self.assertTrue(mock_log.warn.called)
|
||||
self.assertRegexpMatches(mock_log.warn.call_args[0][0], 'partition mismatch')
|
||||
self.assertRegex(mock_log.warn.call_args[0][0], 'partition mismatch')
|
||||
|
||||
|
||||
class TestExtension(django.test.TestCase):
|
||||
@@ -265,7 +265,7 @@ class TestExtension(django.test.TestCase):
|
||||
|
||||
def test_get_scheme(self):
|
||||
self.assertEqual(UserPartition.get_scheme('cohort'), CohortPartitionScheme)
|
||||
with self.assertRaisesRegexp(UserPartitionError, 'Unrecognized scheme'):
|
||||
with self.assertRaisesRegex(UserPartitionError, 'Unrecognized scheme'):
|
||||
UserPartition.get_scheme('other')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user