Repository: oppia/oppia

Issue:
Add lint check for self.assertEquals and fix corresponding problems
At quite a few places in the code base, we have used `self.assertEquals` which has been deprecated: https://docs.python.org/2/library/unittest.html#deprecated-aliases. This is a tracking issue to add a check to prevent its use and replace all instances with `self.assertEqual`.
Add lint check for self.assertEquals and fix corresponding problems
At quite a few places in the code base, we have used `self.assertEquals` which has been deprecated: https://docs.python.org/2/library/unittest.html#deprecated-aliases. This is a tracking issue to add a check to prevent its use and replace all instances with `self.assertEqual`.


Discussion:

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -193,6 +193,14 @@
             'core/tests/test_utils.py',
             'core/tests/performance_framework/perf_domain.py'),
         'excluded_dirs': ('scripts/',)
+    },
+    {
+        'regexp': r'self.assertEquals\(',
+        'message': "Please do not use self.assertEquals method. " +
+                   "This method has been deprecated. Instead use " +
+                   "self.assertEqual method.",
+        'excluded_files': (),
+        'excluded_dirs': ()
     }
 ]
 


Test patch:
diff --git a/core/controllers/creator_dashboard_test.py b/core/controllers/creator_dashboard_test.py
--- a/core/controllers/creator_dashboard_test.py
+++ b/core/controllers/creator_dashboard_test.py
@@ -158,10 +158,10 @@ def test_one_play_for_single_exploration(self):
 
         self._run_user_stats_aggregator_job()
         user_model = user_models.UserStatsModel.get(self.owner_id_1)
-        self.assertEquals(user_model.total_plays, 1)
-        self.assertEquals(
+        self.assertEqual(user_model.total_plays, 1)
+        self.assertEqual(
             user_model.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(user_model.num_ratings, 0)
+        self.assertEqual(user_model.num_ratings, 0)
         self.assertIsNone(user_model.average_ratings)
         self.logout()
 
@@ -178,11 +178,11 @@ def test_one_rating_for_single_exploration(self):
 
         self._run_user_stats_aggregator_job()
         user_model = user_models.UserStatsModel.get(self.owner_id_1)
-        self.assertEquals(user_model.total_plays, 0)
-        self.assertEquals(
+        self.assertEqual(user_model.total_plays, 0)
+        self.assertEqual(
             user_model.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(user_model.num_ratings, 1)
-        self.assertEquals(user_model.average_ratings, 4)
+        self.assertEqual(user_model.num_ratings, 1)
+        self.assertEqual(user_model.average_ratings, 4)
         self.logout()
 
     def test_one_play_and_rating_for_single_exploration(self):
@@ -204,11 +204,11 @@ def test_one_play_and_rating_for_single_exploration(self):
 
         self._run_user_stats_aggregator_job()
         user_model = user_models.UserStatsModel.get(self.owner_id_1)
-        self.assertEquals(user_model.total_plays, 1)
-        self.assertEquals(
+        self.assertEqual(user_model.total_plays, 1)
+        self.assertEqual(
             user_model.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(user_model.num_ratings, 1)
-        self.assertEquals(user_model.average_ratings, 3)
+        self.assertEqual(user_model.num_ratings, 1)
+        self.assertEqual(user_model.average_ratings, 3)
         self.logout()
 
     def test_multiple_plays_and_ratings_for_single_exploration(self):
@@ -232,11 +232,11 @@ def test_multiple_plays_and_ratings_for_single_exploration(self):
 
         self._run_user_stats_aggregator_job()
         user_model = user_models.UserStatsModel.get(self.owner_id_1)
-        self.assertEquals(user_model.total_plays, 4)
-        self.assertEquals(
+        self.assertEqual(user_model.total_plays, 4)
+        self.assertEqual(
             user_model.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(user_model.num_ratings, 3)
-        self.assertEquals(user_model.average_ratings, 4)
+        self.assertEqual(user_model.num_ratings, 3)
+        self.assertEqual(user_model.average_ratings, 4)
         self.logout()
 
     def test_one_play_and_rating_for_multiple_explorations(self):
@@ -260,11 +260,11 @@ def test_one_play_and_rating_for_multiple_explorations(self):
 
         self._run_user_stats_aggregator_job()
         user_model = user_models.UserStatsModel.get(self.owner_id_1)
-        self.assertEquals(user_model.total_plays, 1)
-        self.assertEquals(
+        self.assertEqual(user_model.total_plays, 1)
+        self.assertEqual(
             user_model.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(user_model.num_ratings, 1)
-        self.assertEquals(user_model.average_ratings, 4)
+        self.assertEqual(user_model.num_ratings, 1)
+        self.assertEqual(user_model.average_ratings, 4)
         self.logout()
 
     def test_multiple_plays_and_ratings_for_multiple_explorations(self):
@@ -294,11 +294,11 @@ def test_multiple_plays_and_ratings_for_multiple_explorations(self):
         self._run_user_stats_aggregator_job()
 
         user_model = user_models.UserStatsModel.get(self.owner_id_1)
-        self.assertEquals(user_model.total_plays, 3)
-        self.assertEquals(
+        self.assertEqual(user_model.total_plays, 3)
+        self.assertEqual(
             user_model.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(user_model.num_ratings, 3)
-        self.assertEquals(user_model.average_ratings, 10 / 3.0)
+        self.assertEqual(user_model.num_ratings, 3)
+        self.assertEqual(user_model.average_ratings, 10 / 3.0)
         self.logout()
 
     def test_stats_for_single_exploration_with_multiple_owners(self):
@@ -333,19 +333,19 @@ def test_stats_for_single_exploration_with_multiple_owners(self):
 
         user_model_1 = user_models.UserStatsModel.get(
             self.owner_id_1)
-        self.assertEquals(user_model_1.total_plays, 2)
-        self.assertEquals(
+        self.assertEqual(user_model_1.total_plays, 2)
+        self.assertEqual(
             user_model_1.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(user_model_1.num_ratings, 3)
-        self.assertEquals(user_model_1.average_ratings, 4)
+        self.assertEqual(user_model_1.num_ratings, 3)
+        self.assertEqual(user_model_1.average_ratings, 4)
 
         user_model_2 = user_models.UserStatsModel.get(
             self.owner_id_2)
-        self.assertEquals(user_model_2.total_plays, 2)
-        self.assertEquals(
+        self.assertEqual(user_model_2.total_plays, 2)
+        self.assertEqual(
             user_model_2.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(user_model_2.num_ratings, 3)
-        self.assertEquals(user_model_2.average_ratings, 4)
+        self.assertEqual(user_model_2.num_ratings, 3)
+        self.assertEqual(user_model_2.average_ratings, 4)
         self.logout()
 
     def test_stats_for_multiple_explorations_with_multiple_owners(self):
@@ -390,13 +390,13 @@ def test_stats_for_multiple_explorations_with_multiple_owners(self):
         }
 
         user_model_2 = user_models.UserStatsModel.get(self.owner_id_2)
-        self.assertEquals(
+        self.assertEqual(
             user_model_2.total_plays, expected_results['total_plays'])
-        self.assertEquals(
+        self.assertEqual(
             user_model_2.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(
+        self.assertEqual(
             user_model_2.num_ratings, expected_results['num_ratings'])
-        self.assertEquals(
+        self.assertEqual(
             user_model_2.average_ratings, expected_results['average_ratings'])
         self.logout()
 
@@ -405,13 +405,13 @@ def test_stats_for_multiple_explorations_with_multiple_owners(self):
         self.assertEqual(len(response['explorations_list']), 2)
 
         user_model_1 = user_models.UserStatsModel.get(self.owner_id_1)
-        self.assertEquals(
+        self.assertEqual(
             user_model_1.total_plays, expected_results['total_plays'])
-        self.assertEquals(
+        self.assertEqual(
             user_model_1.impact_score, self.USER_IMPACT_SCORE_DEFAULT)
-        self.assertEquals(
+        self.assertEqual(
             user_model_1.num_ratings, expected_results['num_ratings'])
-        self.assertEquals(
+        self.assertEqual(
             user_model_1.average_ratings, expected_results['average_ratings'])
         self.logout()
 
diff --git a/core/controllers/feedback_test.py b/core/controllers/feedback_test.py
--- a/core/controllers/feedback_test.py
+++ b/core/controllers/feedback_test.py
@@ -522,7 +522,7 @@ def test_feedback_threads_with_suggestions(self):
             response = self.get_json(
                 '%s/%s' % (
                     feconf.FEEDBACK_THREADLIST_URL_PREFIX, self.EXP_ID))
-            self.assertEquals(response['feedback_thread_dicts'], [])
+            self.assertEqual(response['feedback_thread_dicts'], [])
             expected_thread_dict = {
                 'original_author_username': self.USER_USERNAME,
                 'status': feedback_models.STATUS_CHOICES_OPEN,
diff --git a/core/controllers/old_feedback_test.py b/core/controllers/old_feedback_test.py
--- a/core/controllers/old_feedback_test.py
+++ b/core/controllers/old_feedback_test.py
@@ -395,7 +395,7 @@ def test_feedback_threads_with_suggestions(self):
             response = self.get_json(
                 '%s/%s' % (
                     feconf.FEEDBACK_THREADLIST_URL_PREFIX, self.EXP_ID))
-            self.assertEquals(response['feedback_thread_dicts'], [])
+            self.assertEqual(response['feedback_thread_dicts'], [])
             expected_thread_dict = {
                 'original_author_username': self.USER_USERNAME,
                 'status': feedback_models.STATUS_CHOICES_OPEN,
diff --git a/core/controllers/recent_commits_test.py b/core/controllers/recent_commits_test.py
--- a/core/controllers/recent_commits_test.py
+++ b/core/controllers/recent_commits_test.py
@@ -53,7 +53,7 @@ def test_get_recent_commits(self):
         response_dict = self.get_json(
             feconf.RECENT_COMMITS_DATA_URL,
             params={'query_type': 'all_non_private_commits'})
-        self.assertEquals(len(response_dict['results']), 2)
+        self.assertEqual(len(response_dict['results']), 2)
         self.assertDictContainsSubset(
             {'username': 'Janet', 'exploration_id': 'exp_1',
              'post_commit_status': 'public', 'version': 0,
@@ -76,8 +76,8 @@ def test_get_recent_commits_explorations(self):
         response_dict = self.get_json(
             feconf.RECENT_COMMITS_DATA_URL,
             params={'query_type': 'all_non_private_commits'})
-        self.assertEquals(len(response_dict['exp_ids_to_exp_data']), 1)
-        self.assertEquals(
+        self.assertEqual(len(response_dict['exp_ids_to_exp_data']), 1)
+        self.assertEqual(
             response_dict['exp_ids_to_exp_data']['exp_1']['title'],
             'MyExploration')
         self.logout()
@@ -101,7 +101,7 @@ def test_get_recent_commits_three_pages_with_cursor(self):
             feconf.RECENT_COMMITS_DATA_URL,
             params={'query_type': 'all_non_private_commits'})
 
-        self.assertEquals(
+        self.assertEqual(
             len(response_dict['results']),
             feconf.COMMIT_LIST_PAGE_SIZE)
         self.assertTrue(response_dict['more'])
@@ -113,7 +113,7 @@ def test_get_recent_commits_three_pages_with_cursor(self):
                 'query_type': 'all_non_private_commits',
                 'cursor': cursor
             })
-        self.assertEquals(
+        self.assertEqual(
             len(response_dict['results']),
             feconf.COMMIT_LIST_PAGE_SIZE)
         self.assertTrue(response_dict['more'])
@@ -125,5 +125,5 @@ def test_get_recent_commits_three_pages_with_cursor(self):
                 'cursor': cursor
             })
         self.assertFalse(response_dict['more'])
-        self.assertEquals(len(response_dict['results']), 2)
+        self.assertEqual(len(response_dict['results']), 2)
         self.logout()
diff --git a/core/domain/exp_jobs_one_off_test.py b/core/domain/exp_jobs_one_off_test.py
--- a/core/domain/exp_jobs_one_off_test.py
+++ b/core/domain/exp_jobs_one_off_test.py
@@ -493,7 +493,7 @@ def test_contributors_with_only_reverts_not_included(self):
 
         # Check that the User A has only 2 commits after user b has reverted
         # to version 2.
-        self.assertEquals(2, exploration_summary.contributors_summary[user_a_id]) # pylint: disable=line-too-long
+        self.assertEqual(2, exploration_summary.contributors_summary[user_a_id]) # pylint: disable=line-too-long
 
     def test_reverts_not_counted(self):
         """Test that if both non-revert commits and revert are
diff --git a/core/domain/state_domain_test.py b/core/domain/state_domain_test.py
--- a/core/domain/state_domain_test.py
+++ b/core/domain/state_domain_test.py
@@ -459,7 +459,7 @@ def test_hints_validation(self):
 
         # Add hint and delete hint.
         init_state.add_hint(state_domain.SubtitledHtml('hint_2', 'new hint'))
-        self.assertEquals(
+        self.assertEqual(
             init_state.interaction.hints[1].hint_content.html,
             'new hint')
         init_state.add_hint(
@@ -472,7 +472,7 @@ def test_hints_validation(self):
             'hint_3': {},
             'solution': {}
         })
-        self.assertEquals(len(init_state.interaction.hints), 2)
+        self.assertEqual(len(init_state.interaction.hints), 2)
         exploration.validate()
 
     def test_solution_validation(self):
@@ -484,7 +484,7 @@ def test_solution_validation(self):
         exploration.validate()
 
         # Solution should be set to None as default.
-        self.assertEquals(init_state.interaction.solution, None)
+        self.assertEqual(init_state.interaction.solution, None)
 
         init_state.add_hint(state_domain.SubtitledHtml('hint_1', {}))
         solution = {
diff --git a/core/domain/user_jobs_continuous_test.py b/core/domain/user_jobs_continuous_test.py
--- a/core/domain/user_jobs_continuous_test.py
+++ b/core/domain/user_jobs_continuous_test.py
@@ -835,11 +835,11 @@ def test_realtime_layer_batch_job_no_ratings_plays(self):
         user_stats = (
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.user_a_id))
-        self.assertEquals(
+        self.assertEqual(
             user_stats['total_plays'], 0)
-        self.assertEquals(
+        self.assertEqual(
             user_stats['num_ratings'], 0)
-        self.assertEquals(
+        self.assertEqual(
             user_stats['average_ratings'], None)
 
     def test_realtime_layer_batch_job_single_rating(self):
@@ -850,9 +850,9 @@ def test_realtime_layer_batch_job_single_rating(self):
         user_stats = (
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.user_a_id))
-        self.assertEquals(user_stats['total_plays'], 0)
-        self.assertEquals(user_stats['num_ratings'], 1)
-        self.assertEquals(user_stats['average_ratings'], 4)
+        self.assertEqual(user_stats['total_plays'], 0)
+        self.assertEqual(user_stats['num_ratings'], 1)
+        self.assertEqual(user_stats['average_ratings'], 4)
 
     def test_realtime_layer_batch_job_single_exploration_one_owner(self):
         exploration = self._create_exploration(
@@ -869,9 +869,9 @@ def test_realtime_layer_batch_job_single_exploration_one_owner(self):
         user_stats = (
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.user_a_id))
-        self.assertEquals(user_stats['total_plays'], 2)
-        self.assertEquals(user_stats['num_ratings'], 2)
-        self.assertEquals(user_stats['average_ratings'], 3.5)
+        self.assertEqual(user_stats['total_plays'], 2)
+        self.assertEqual(user_stats['num_ratings'], 2)
+        self.assertEqual(user_stats['average_ratings'], 3.5)
 
     def test_realtime_layer_batch_job_single_exploration_multiple_owners(self):
         exploration = self._create_exploration(
@@ -899,22 +899,22 @@ def test_realtime_layer_batch_job_single_exploration_multiple_owners(self):
         user_stats_1 = (
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.user_a_id))
-        self.assertEquals(
+        self.assertEqual(
             user_stats_1['total_plays'], expected_results['total_plays'])
-        self.assertEquals(
+        self.assertEqual(
             user_stats_1['num_ratings'], expected_results['num_ratings'])
-        self.assertEquals(
+        self.assertEqual(
             user_stats_1['average_ratings'],
             expected_results['average_ratings'])
 
         user_stats_2 = (
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.user_b_id))
-        self.assertEquals(
+        self.assertEqual(
             user_stats_2['total_plays'], expected_results['total_plays'])
-        self.assertEquals(
+        self.assertEqual(
             user_stats_2['num_ratings'], expected_results['num_ratings'])
-        self.assertEquals(
+        self.assertEqual(
             user_stats_2['average_ratings'],
             expected_results['average_ratings'])
 
@@ -930,9 +930,9 @@ def test_realtime_layer_batch_job_multiple_explorations_one_owner(self):
         user_stats = (
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.user_a_id))
-        self.assertEquals(user_stats['total_plays'], 0)
-        self.assertEquals(user_stats['num_ratings'], 5)
-        self.assertEquals(user_stats['average_ratings'], 18 / 5.0)
+        self.assertEqual(user_stats['total_plays'], 0)
+        self.assertEqual(user_stats['num_ratings'], 5)
+        self.assertEqual(user_stats['average_ratings'], 18 / 5.0)
 
     def test_realtime_layer_batch_job_user_rate_same_exp_multiple_times(self):
         self._create_exploration(
@@ -944,18 +944,18 @@ def test_realtime_layer_batch_job_user_rate_same_exp_multiple_times(self):
         user_stats = (
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.user_a_id))
-        self.assertEquals(user_stats['total_plays'], 0)
-        self.assertEquals(user_stats['num_ratings'], 1)
-        self.assertEquals(user_stats['average_ratings'], 5)
+        self.assertEqual(user_stats['total_plays'], 0)
+        self.assertEqual(user_stats['num_ratings'], 1)
+        self.assertEqual(user_stats['average_ratings'], 5)
 
         self._record_exploration_rating_for_user(
             exp_id_1, self.user_b_id, 3, old_rating=5)
         user_stats = (
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.user_a_id))
-        self.assertEquals(user_stats['total_plays'], 0)
-        self.assertEquals(user_stats['num_ratings'], 1)
-        self.assertEquals(user_stats['average_ratings'], 3)
+        self.assertEqual(user_stats['total_plays'], 0)
+        self.assertEqual(user_stats['num_ratings'], 1)
+        self.assertEqual(user_stats['average_ratings'], 3)
 
     def test_both_realtime_layer_and_batch_data(self):
         exploration_1 = self._create_exploration(self.EXP_ID_1, self.user_a_id)
@@ -993,6 +993,6 @@ def test_both_realtime_layer_and_batch_data(self):
                 self.user_a_id))
         # After recording two start events, the total plays is now increased by
         # two.
-        self.assertEquals(user_stats['total_plays'], 16)
-        self.assertEquals(user_stats['num_ratings'], 10)
-        self.assertEquals(user_stats['average_ratings'], 32 / 10.0)
+        self.assertEqual(user_stats['total_plays'], 16)
+        self.assertEqual(user_stats['num_ratings'], 10)
+        self.assertEqual(user_stats['average_ratings'], 32 / 10.0)
diff --git a/core/domain/user_jobs_one_off_test.py b/core/domain/user_jobs_one_off_test.py
--- a/core/domain/user_jobs_one_off_test.py
+++ b/core/domain/user_jobs_one_off_test.py
@@ -758,7 +758,7 @@ def test_weekly_stats_if_continuous_stats_job_has_not_been_run(self):
 
         weekly_stats = user_services.get_weekly_dashboard_stats(self.owner_id)
         self.assertEqual(weekly_stats, None)
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_last_week_dashboard_stats(self.owner_id), None)
 
         with self.swap(
@@ -776,7 +776,7 @@ def test_weekly_stats_if_continuous_stats_job_has_not_been_run(self):
             }
         }]
         self.assertEqual(weekly_stats, expected_results_list)
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_last_week_dashboard_stats(self.owner_id),
             expected_results_list[0])
 
@@ -955,7 +955,7 @@ def _mock_get_date_after_one_week():
         ]
         weekly_stats = user_services.get_weekly_dashboard_stats(self.owner_id)
         self.assertEqual(weekly_stats, expected_results_list)
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_last_week_dashboard_stats(self.owner_id),
             expected_results_list[1])
 
diff --git a/core/domain/user_services_test.py b/core/domain/user_services_test.py
--- a/core/domain/user_services_test.py
+++ b/core/domain/user_services_test.py
@@ -46,7 +46,7 @@ def test_set_and_get_username(self):
         user_services.create_new_user(user_id, 'user@example.com')
 
         user_services.set_username(user_id, username)
-        self.assertEquals(username, user_services.get_username(user_id))
+        self.assertEqual(username, user_services.get_username(user_id))
 
     def test_get_username_for_system_user(self):
         self.assertEqual(
@@ -83,7 +83,7 @@ def test_get_username_for_nonexistent_user(self):
 
     def test_get_username_none(self):
         user_services.create_new_user('fakeUser', 'user@example.com')
-        self.assertEquals(None, user_services.get_username('fakeUser'))
+        self.assertEqual(None, user_services.get_username('fakeUser'))
 
     def test_is_username_taken_false(self):
         self.assertFalse(user_services.is_username_taken('fakeUsername'))
@@ -137,14 +137,14 @@ def test_get_email_from_username(self):
 
         user_services.create_new_user(user_id, user_email)
         user_services.set_username(user_id, username)
-        self.assertEquals(user_services.get_username(user_id), username)
+        self.assertEqual(user_services.get_username(user_id), username)
 
         # Handle usernames that exist.
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_email_from_username(username), user_email)
 
         # Handle usernames in the same equivalence class correctly.
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_email_from_username('USERNAME'), user_email)
 
         # Return None for usernames which don't exist.
@@ -158,14 +158,14 @@ def test_get_user_id_from_username(self):
 
         user_services.create_new_user(user_id, user_email)
         user_services.set_username(user_id, username)
-        self.assertEquals(user_services.get_username(user_id), username)
+        self.assertEqual(user_services.get_username(user_id), username)
 
         # Handle usernames that exist.
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_user_id_from_username(username), user_id)
 
         # Handle usernames in the same equivalence class correctly.
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_user_id_from_username('USERNAME'), user_id)
 
         # Return None for usernames which don't exist.
@@ -249,12 +249,12 @@ def test_set_and_get_user_email_preferences(self):
         # When UserEmailPreferencesModel is yet to be created,
         # the value returned by get_email_preferences() should be True.
         email_preferences = user_services.get_email_preferences(user_id)
-        self.assertEquals(
+        self.assertEqual(
             email_preferences.can_receive_editor_role_email,
             feconf.DEFAULT_EDITOR_ROLE_EMAIL_PREFERENCE)
 
         email_preferences = user_services.get_email_preferences(user_id)
-        self.assertEquals(
+        self.assertEqual(
             email_preferences.can_receive_feedback_message_email,
             feconf.DEFAULT_FEEDBACK_MESSAGE_EMAIL_PREFERENCE)
 
@@ -267,10 +267,10 @@ def test_set_and_get_user_email_preferences(self):
             feconf.DEFAULT_SUBSCRIPTION_EMAIL_PREFERENCE)
 
         email_preferences = user_services.get_email_preferences(user_id)
-        self.assertEquals(
+        self.assertEqual(
             email_preferences.can_receive_editor_role_email,
             feconf.DEFAULT_EDITOR_ROLE_EMAIL_PREFERENCE)
-        self.assertEquals(
+        self.assertEqual(
             email_preferences.can_receive_feedback_message_email,
             feconf.DEFAULT_FEEDBACK_MESSAGE_EMAIL_PREFERENCE)
 
@@ -303,10 +303,10 @@ def test_set_and_get_user_email_preferences_for_exploration(self):
         self.assertIsNone(exploration_user_model)
         email_preferences = user_services.get_email_preferences_for_exploration(
             user_id, exploration_id)
-        self.assertEquals(
+        self.assertEqual(
             email_preferences.mute_feedback_notifications,
             feconf.DEFAULT_FEEDBACK_NOTIFICATIONS_MUTED_PREFERENCE)
-        self.assertEquals(
+        self.assertEqual(
             email_preferences.mute_suggestion_notifications,
             feconf.DEFAULT_SUGGESTION_NOTIFICATIONS_MUTED_PREFERENCE)
 
@@ -321,10 +321,10 @@ def test_set_and_get_user_email_preferences_for_exploration(self):
 
         email_preferences = user_services.get_email_preferences_for_exploration(
             user_id, exploration_id)
-        self.assertEquals(
+        self.assertEqual(
             email_preferences.mute_feedback_notifications,
             feconf.DEFAULT_FEEDBACK_NOTIFICATIONS_MUTED_PREFERENCE)
-        self.assertEquals(
+        self.assertEqual(
             email_preferences.mute_suggestion_notifications,
             feconf.DEFAULT_SUGGESTION_NOTIFICATIONS_MUTED_PREFERENCE)
 
@@ -335,7 +335,7 @@ def test_set_and_get_user_email_preferences_for_exploration(self):
 
         email_preferences = user_services.get_email_preferences_for_exploration(
             user_id, exploration_id)
-        self.assertEquals(
+        self.assertEqual(
             email_preferences.mute_feedback_notifications,
             feconf.DEFAULT_FEEDBACK_NOTIFICATIONS_MUTED_PREFERENCE)
         self.assertTrue(email_preferences.mute_suggestion_notifications)
@@ -759,7 +759,7 @@ def test_get_user_dashboard_stats(self):
                 'num_completions': 0,
                 'state_stats_mapping': {}
             })
-        self.assertEquals(
+        self.assertEqual(
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.owner_id),
             {
@@ -770,7 +770,7 @@ def test_get_user_dashboard_stats(self):
         (user_jobs_continuous_test.ModifiedUserStatsAggregator
          .start_computation())
         self.process_and_flush_pending_tasks()
-        self.assertEquals(
+        self.assertEqual(
             user_jobs_continuous.UserStatsAggregator.get_dashboard_stats(
                 self.owner_id),
             {
@@ -786,9 +786,9 @@ def test_get_weekly_dashboard_stats_when_stats_model_is_none(self):
         event_services.StartExplorationEventHandler.record(
             self.EXP_ID, 1, init_state_name, self.USER_SESSION_ID, {},
             feconf.PLAY_TYPE_NORMAL)
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_weekly_dashboard_stats(self.owner_id), None)
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_last_week_dashboard_stats(self.owner_id), None)
 
         with self.swap(
@@ -797,7 +797,7 @@ def test_get_weekly_dashboard_stats_when_stats_model_is_none(self):
             self._mock_get_current_date_as_string):
             user_services.update_dashboard_stats_log(self.owner_id)
 
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_weekly_dashboard_stats(self.owner_id), [{
                 self.CURRENT_DATE_AS_STRING: {
                     'total_plays': 0,
@@ -821,18 +821,18 @@ def test_get_weekly_dashboard_stats(self):
                 'state_stats_mapping': {}
             })
 
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_weekly_dashboard_stats(self.owner_id), None)
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_last_week_dashboard_stats(self.owner_id), None)
 
         (user_jobs_continuous_test.ModifiedUserStatsAggregator
          .start_computation())
         self.process_and_flush_pending_tasks()
 
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_weekly_dashboard_stats(self.owner_id), None)
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_last_week_dashboard_stats(self.owner_id), None)
 
         with self.swap(
@@ -841,7 +841,7 @@ def test_get_weekly_dashboard_stats(self):
             self._mock_get_current_date_as_string):
             user_services.update_dashboard_stats_log(self.owner_id)
 
-        self.assertEquals(
+        self.assertEqual(
             user_services.get_weekly_dashboard_stats(self.owner_id), [{
                 self.CURRENT_DATE_AS_STRING: {
                     'total_plays': 1,
diff --git a/core/jobs_test.py b/core/jobs_test.py
--- a/core/jobs_test.py
+++ b/core/jobs_test.py
@@ -255,10 +255,10 @@ def test_cancel_kills_queued_job(self):
         DummyJobManager.cancel(job_id, 'admin_user_id')
 
         self.assertFalse(DummyJobManager.is_active(job_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_status_code(job_id), jobs.STATUS_CODE_CANCELED)
         self.assertIsNone(DummyJobManager.get_output(job_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_error(job_id), 'Canceled by admin_user_id')
 
     def test_cancel_kills_started_job(self):
@@ -275,11 +275,11 @@ def test_cancel_kills_started_job(self):
             DummyJobManager.register_completion(job_id, ['job_output'])
 
         self.assertFalse(DummyJobManager.is_active(job_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_status_code(job_id), jobs.STATUS_CODE_CANCELED)
         # Note that no results are recorded for this job.
         self.assertIsNone(DummyJobManager.get_output(job_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_error(job_id), 'Canceled by admin_user_id')
 
     def test_cancel_does_not_kill_completed_job(self):
@@ -290,7 +290,7 @@ def test_cancel_does_not_kill_completed_job(self):
         self.process_and_flush_pending_tasks()
 
         self.assertFalse(DummyJobManager.is_active(job_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_status_code(job_id),
             jobs.STATUS_CODE_COMPLETED)
         # Cancel the job after it has finished.
@@ -299,10 +299,10 @@ def test_cancel_does_not_kill_completed_job(self):
 
         # The job should still have 'completed' status.
         self.assertFalse(DummyJobManager.is_active(job_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_status_code(job_id),
             jobs.STATUS_CODE_COMPLETED)
-        self.assertEquals(DummyJobManager.get_output(job_id), ['output'])
+        self.assertEqual(DummyJobManager.get_output(job_id), ['output'])
         self.assertIsNone(DummyJobManager.get_error(job_id))
 
     def test_cancel_does_not_kill_failed_job(self):
@@ -314,7 +314,7 @@ def test_cancel_does_not_kill_failed_job(self):
             self.process_and_flush_pending_tasks()
 
         self.assertFalse(DummyFailingJobManager.is_active(job_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyFailingJobManager.get_status_code(job_id),
             jobs.STATUS_CODE_FAILED)
         # Cancel the job after it has finished.
@@ -323,7 +323,7 @@ def test_cancel_does_not_kill_failed_job(self):
 
         # The job should still have 'failed' status.
         self.assertFalse(DummyFailingJobManager.is_active(job_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyFailingJobManager.get_status_code(job_id),
             jobs.STATUS_CODE_FAILED)
         self.assertIsNone(DummyFailingJobManager.get_output(job_id))
@@ -342,17 +342,17 @@ def test_cancelling_multiple_unfinished_jobs(self):
 
         self.assertFalse(DummyJobManager.is_active(job1_id))
         self.assertFalse(DummyJobManager.is_active(job2_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_status_code(job1_id),
             jobs.STATUS_CODE_CANCELED)
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_status_code(job2_id),
             jobs.STATUS_CODE_CANCELED)
         self.assertIsNone(DummyJobManager.get_output(job1_id))
         self.assertIsNone(DummyJobManager.get_output(job2_id))
-        self.assertEquals(
+        self.assertEqual(
             'Canceled by admin_user_id', DummyJobManager.get_error(job1_id))
-        self.assertEquals(
+        self.assertEqual(
             'Canceled by admin_user_id', DummyJobManager.get_error(job2_id))
 
     def test_cancelling_one_unfinished_job(self):
@@ -370,15 +370,15 @@ def test_cancelling_one_unfinished_job(self):
 
         self.assertFalse(DummyJobManager.is_active(job1_id))
         self.assertFalse(DummyJobManager.is_active(job2_id))
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_status_code(job1_id),
             jobs.STATUS_CODE_CANCELED)
-        self.assertEquals(
+        self.assertEqual(
             DummyJobManager.get_status_code(job2_id),
             jobs.STATUS_CODE_COMPLETED)
         self.assertIsNone(DummyJobManager.get_output(job1_id))
-        self.assertEquals(DummyJobManager.get_output(job2_id), ['output'])
-        self.assertEquals(
+        self.assertEqual(DummyJobManager.get_output(job2_id), ['output'])
+        self.assertEqual(
             'Canceled by admin_user_id', DummyJobManager.get_error(job1_id))
         self.assertIsNone(DummyJobManager.get_error(job2_id))
 
@@ -387,34 +387,34 @@ def test_compress_output_list_with_single_char_outputs(self):
         expected_output = ['1', '2', '3', '<TRUNCATED>']
         actual_output = jobs.BaseJobManager._compress_output_list(  # pylint: disable=protected-access
             input_list, test_only_max_output_len_chars=3)
-        self.assertEquals(actual_output, expected_output)
+        self.assertEqual(actual_output, expected_output)
 
     def test_compress_output_list_with_multi_char_outputs(self):
         input_list = ['abcd', 'efgh', 'ijkl']
         expected_output = ['abcd', 'efgh', 'ij <TRUNCATED>']
         actual_output = jobs.BaseJobManager._compress_output_list(  # pylint: disable=protected-access
             input_list, test_only_max_output_len_chars=10)
-        self.assertEquals(actual_output, expected_output)
+        self.assertEqual(actual_output, expected_output)
 
     def test_compress_output_list_with_zero_max_output_len(self):
         input_list = [1, 2, 3]
         expected_output = ['<TRUNCATED>']
         actual_output = jobs.BaseJobManager._compress_output_list(  # pylint: disable=protected-access
             input_list, test_only_max_output_len_chars=0)
-        self.assertEquals(actual_output, expected_output)
+        self.assertEqual(actual_output, expected_output)
 
     def test_compress_output_list_with_exact_max_output_len(self):
         input_list = ['abc']
         expected_output = ['abc']
         actual_output = jobs.BaseJobManager._compress_output_list(  # pylint: disable=protected-access
             input_list, test_only_max_output_len_chars=3)
-        self.assertEquals(actual_output, expected_output)
+        self.assertEqual(actual_output, expected_output)
 
     def test_compress_output_list_with_empty_outputs(self):
         input_list = []
         expected_output = []
         actual_output = jobs.BaseJobManager._compress_output_list(input_list)  # pylint: disable=protected-access
-        self.assertEquals(actual_output, expected_output)
+        self.assertEqual(actual_output, expected_output)
 
     def test_compress_output_list_with_duplicate_outputs(self):
         input_list = ['bar', 'foo'] * 3
@@ -423,14 +423,14 @@ def test_compress_output_list_with_duplicate_outputs(self):
             input_list,
             # Make sure no output gets truncated.
             test_only_max_output_len_chars=sum(len(s) for s in expected_output))
-        self.assertEquals(actual_output, expected_output)
+        self.assertEqual(actual_output, expected_output)
 
     def test_compress_output_list_with_truncated_duplicate_outputs(self):
         input_list = ['supercalifragilisticexpialidocious'] * 3
         expected_output = ['(3x) super <TRUNCATED>']
         actual_output = jobs.BaseJobManager._compress_output_list(  # pylint: disable=protected-access
             input_list, test_only_max_output_len_chars=10)
-        self.assertEquals(actual_output, expected_output)
+        self.assertEqual(actual_output, expected_output)
 
 
 SUM_MODEL_ID = 'all_data_id'
diff --git a/core/storage/collection/gae_models_test.py b/core/storage/collection/gae_models_test.py
--- a/core/storage/collection/gae_models_test.py
+++ b/core/storage/collection/gae_models_test.py
@@ -37,7 +37,7 @@ def test_get_collection_count(self):
 
         num_collections = (
             collection_models.CollectionModel.get_collection_count())
-        self.assertEquals(num_collections, 1)
+        self.assertEqual(num_collections, 1)
 
 
 class CollectionRightsModelUnitTest(test_utils.GenericTestBase):
@@ -79,8 +79,8 @@ def test_get_all_non_private_commits(self):
         commits = (
             collection_models.CollectionCommitLogEntryModel
             .get_all_non_private_commits(2, None, None))
-        self.assertEquals(False, commits[2])
-        self.assertEquals('collection--b--0', commits[0][0].id)
+        self.assertEqual(False, commits[2])
+        self.assertEqual('collection--b--0', commits[0][0].id)
 
 
 class CollectionSummaryModelUnitTest(test_utils.GenericTestBase):
diff --git a/core/storage/exploration/gae_models_test.py b/core/storage/exploration/gae_models_test.py
--- a/core/storage/exploration/gae_models_test.py
+++ b/core/storage/exploration/gae_models_test.py
@@ -36,13 +36,13 @@ def test_get_exploration_count(self):
             category='A Category', objective='An Objective')
         exp_services.save_new_exploration('id', exploration)
 
-        self.assertEquals(
+        self.assertEqual(
             exploration_models.ExplorationModel.get_exploration_count(), 1)
         saved_exploration = (
             exploration_models.ExplorationModel.get_all().fetch(1)[0])
-        self.assertEquals(saved_exploration.title, 'A Title')
-        self.assertEquals(saved_exploration.category, 'A Category')
-        self.assertEquals(saved_exploration.objective, 'An Objective')
+        self.assertEqual(saved_exploration.title, 'A Title')
+        self.assertEqual(saved_exploration.category, 'A Category')
+        self.assertEqual(saved_exploration.objective, 'An Objective')
 
 
 class ExplorationRightsModelUnitTest(test_utils.GenericTestBase):
@@ -91,7 +91,7 @@ def test_get_all_non_private_commits(self):
             exploration_models.ExplorationCommitLogEntryModel
             .get_all_non_private_commits(2, None, None))
         self.assertFalse(more)
-        self.assertEquals(len(results), 1)
+        self.assertEqual(len(results), 1)
 
 
 class ExpSummaryModelUnitTest(test_utils.GenericTestBase):
diff --git a/core/storage/job/gae_models_test.py b/core/storage/job/gae_models_test.py
--- a/core/storage/job/gae_models_test.py
+++ b/core/storage/job/gae_models_test.py
@@ -52,14 +52,14 @@ def setUp(self):
             status_code=job_models.STATUS_CODE_COMPLETED).put()
 
     def test_get_all_unfinished_jobs(self):
-        self.assertEquals(
+        self.assertEqual(
             job_models.JobModel.get_all_unfinished_jobs(3),
             [job_models.JobModel.get_by_id('MyJobId2')])
 
     def test_get_unfinished_jobs(self):
-        self.assertEquals(
+        self.assertEqual(
             job_models.JobModel.get_unfinished_jobs('JobType1').fetch(1), [])
-        self.assertEquals(
+        self.assertEqual(
             job_models.JobModel.get_unfinished_jobs('JobType2').fetch(1),
             [job_models.JobModel.get_by_id('MyJobId2')])
 
diff --git a/extensions/objects/models/objects_test.py b/extensions/objects/models/objects_test.py
--- a/extensions/objects/models/objects_test.py
+++ b/extensions/objects/models/objects_test.py
@@ -458,7 +458,7 @@ def test_schemas_used_to_define_objects_are_valid(self):
                     schema_utils_test.validate_schema(member.SCHEMA)
                     count += 1
 
-        self.assertEquals(count, 38)
+        self.assertEqual(count, 38)
 
 
 class ObjectDefinitionTests(test_utils.GenericTestBase):
diff --git a/scripts/build_test.py b/scripts/build_test.py
--- a/scripts/build_test.py
+++ b/scripts/build_test.py
@@ -26,14 +26,14 @@ class BuildTests(test_utils.GenericTestBase):
 
     def test_insert_hash(self):
         # pylint: disable=protected-access
-        self.assertEquals(build._insert_hash('file.js', '123456'),
-                          'file.123456.js')
-        self.assertEquals(build._insert_hash('path/to/file.js', '654321'),
-                          'path/to/file.654321.js')
-        self.assertEquals(build._insert_hash('file.min.js', 'abcdef'),
-                          'file.min.abcdef.js')
-        self.assertEquals(build._insert_hash('path/to/file.min.js', 'fedcba'),
-                          'path/to/file.min.fedcba.js')
+        self.assertEqual(build._insert_hash('file.js', '123456'),
+                         'file.123456.js')
+        self.assertEqual(build._insert_hash('path/to/file.js', '654321'),
+                         'path/to/file.654321.js')
+        self.assertEqual(build._insert_hash('file.min.js', 'abcdef'),
+                         'file.min.abcdef.js')
+        self.assertEqual(build._insert_hash('path/to/file.min.js', 'fedcba'),
+                         'path/to/file.min.fedcba.js')
         # pylint: enable=protected-access
 
     def test_is_file_hash_provided_to_frontend(self):
@@ -66,10 +66,10 @@ def test_filter_hashes(self):
             hashes = {'path/to/file.js': '123456',
                       'path/file.min.js': '123456'}
             filtered_hashes = build.filter_hashes(hashes)
-            self.assertEquals(
+            self.assertEqual(
                 filtered_hashes['/path/to/file.js'],
                 hashes['path/to/file.js'])
-            self.assertEquals(
+            self.assertEqual(
                 filtered_hashes['/path/file.min.js'],
                 hashes['path/file.min.js'])