From 70294b0ad2ba10fe725ff8851b683a83a7131ce7 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 30 Dec 2019 10:22:19 -0500 Subject: [PATCH 1/2] Run `2to3 -f asserts . -w` on edx-platform. https://docs.python.org/3.5/library/2to3.html#2to3fixer-asserts --- .../commands/tests/test_create_course.py | 6 +- .../commands/tests/test_delete_course.py | 4 +- .../commands/tests/test_delete_orphans.py | 2 +- .../management/commands/tests/test_export.py | 6 +- .../commands/tests/test_export_olx.py | 6 +- .../commands/tests/test_fix_not_found.py | 4 +- .../commands/tests/test_force_publish.py | 10 +- .../commands/tests/test_generate_courses.py | 4 +- .../commands/tests/test_git_export.py | 24 ++--- .../commands/tests/test_migrate_to_split.py | 8 +- .../tests/test_migrate_transcripts.py | 4 +- .../commands/tests/test_reindex_courses.py | 10 +- .../commands/tests/test_reindex_library.py | 8 +- .../commands/tests/test_video_thumbnails.py | 2 +- .../contentstore/tests/test_contentstore.py | 4 +- .../tests/test_course_settings.py | 22 ++-- .../contentstore/tests/test_crud.py | 4 +- .../contentstore/tests/test_libraries.py | 4 +- .../contentstore/tests/test_orphan.py | 2 +- .../contentstore/tests/test_utils.py | 10 +- .../contentstore/tests/test_video_utils.py | 4 +- cms/djangoapps/contentstore/tests/tests.py | 2 +- .../contentstore/views/tests/test_assets.py | 70 ++++++------ .../views/tests/test_certificates.py | 12 +-- .../views/tests/test_container_page.py | 2 +- .../views/tests/test_course_index.py | 12 +-- .../views/tests/test_import_export.py | 48 ++++----- .../contentstore/views/tests/test_item.py | 16 +-- .../contentstore/views/tests/test_preview.py | 8 +- .../contentstore/views/tests/test_tabs.py | 6 +- .../contentstore/views/tests/test_videos.py | 2 +- .../course_creators/tests/test_admin.py | 14 +-- cms/djangoapps/maintenance/tests.py | 2 +- cms/lib/xblock/tagging/test.py | 28 ++--- .../tests/test_managers.py | 2 +- .../course_modes/tests/test_views.py | 14 +-- common/djangoapps/edxmako/tests.py | 4 +- .../tests/test_transfer_students.py | 8 +- common/djangoapps/student/tests/test_email.py | 26 ++--- .../djangoapps/student/tests/test_events.py | 10 +- .../student/tests/test_password_policy.py | 4 +- common/djangoapps/student/tests/test_tasks.py | 20 ++-- common/djangoapps/student/tests/test_views.py | 6 +- common/djangoapps/student/tests/tests.py | 20 ++-- .../tests/test_remove_social_auth_users.py | 6 +- .../management/commands/tests/test_saml.py | 16 +-- .../third_party_auth/tests/test_admin.py | 14 +-- .../third_party_auth/tests/test_lti.py | 6 +- .../tests/test_pipeline_integration.py | 2 +- .../management/tests/test_tracked_command.py | 2 +- common/djangoapps/track/tests/__init__.py | 2 +- .../djangoapps/track/tests/test_contexts.py | 4 +- .../track/views/tests/test_segmentio.py | 20 ++-- common/djangoapps/util/tests/test_db.py | 18 ++-- .../util/tests/test_keyword_sub_utils.py | 4 +- .../lib/capa/capa/tests/test_answer_pool.py | 70 ++++++------ .../lib/capa/capa/tests/test_capa_problem.py | 6 +- .../lib/capa/capa/tests/test_html_render.py | 2 +- common/lib/capa/capa/tests/test_inputtypes.py | 2 +- .../lib/capa/capa/tests/test_responsetypes.py | 66 ++++++------ common/lib/capa/capa/tests/test_shuffle.py | 26 ++--- .../capa/capa/tests/test_targeted_feedback.py | 48 ++++----- .../tests/test_mixed_modulestore.py | 50 ++++----- .../tests/test_modulestore_settings.py | 6 +- .../xmodule/modulestore/tests/test_mongo.py | 2 +- .../xmodule/modulestore/tests/test_publish.py | 2 +- .../tests/test_split_modulestore.py | 4 +- .../test_split_modulestore_bulk_operations.py | 42 ++++---- .../partitions/tests/test_partitions.py | 18 ++-- common/lib/xmodule/xmodule/tests/__init__.py | 4 +- .../xmodule/xmodule/tests/test_conditional.py | 4 +- .../tests/test_delay_between_attempts.py | 12 +-- .../lib/xmodule/xmodule/tests/test_export.py | 8 +- .../lib/xmodule/xmodule/tests/test_fields.py | 2 +- .../lib/xmodule/xmodule/tests/test_graders.py | 2 +- .../lib/xmodule/xmodule/tests/test_import.py | 14 +-- .../xmodule/xmodule/tests/test_lti20_unit.py | 8 +- .../xmodule/tests/test_randomize_module.py | 6 +- .../xmodule/xmodule/tests/test_sequence.py | 2 +- .../xmodule/tests/test_split_test_module.py | 10 +- .../lib/xmodule/xmodule/tests/test_video.py | 10 +- .../xmodule/tests/test_xblock_wrappers.py | 4 +- .../discussion/test_cohort_management.py | 10 +- .../tests/discussion/test_cohorts.py | 6 +- .../discussion/test_discussion_management.py | 4 +- common/test/acceptance/tests/helpers.py | 2 +- .../tests/lms/test_lms_courseware.py | 6 +- .../lms/test_lms_instructor_dashboard.py | 4 +- .../tests/lms/test_unicode_username_admin.py | 4 +- .../tests/studio/test_studio_outline.py | 24 ++--- .../tests/studio/test_studio_settings.py | 12 +-- lms/djangoapps/branding/tests/test_models.py | 6 +- lms/djangoapps/branding/tests/test_page.py | 4 +- .../bulk_email/tests/test_course_optout.py | 10 +- lms/djangoapps/bulk_email/tests/test_email.py | 62 +++++------ .../bulk_email/tests/test_err_handling.py | 38 +++---- lms/djangoapps/bulk_email/tests/test_forms.py | 14 +-- .../bulk_email/tests/test_signals.py | 2 +- lms/djangoapps/bulk_email/tests/test_tasks.py | 48 ++++----- lms/djangoapps/ccx/tests/test_overrides.py | 6 +- lms/djangoapps/ccx/tests/test_views.py | 2 +- .../tests/test_cert_management.py | 4 +- .../tests/test_create_fake_cert.py | 2 +- .../certificates/tests/test_models.py | 10 +- .../certificates/tests/test_tasks.py | 2 +- .../tests/test_dashboard_data.py | 46 ++++---- .../commerce/api/v1/tests/test_serializers.py | 4 +- lms/djangoapps/commerce/tests/test_views.py | 6 +- .../course_api/blocks/tests/test_api.py | 12 +-- .../blocks/tests/test_serializers.py | 20 ++-- .../course_api/blocks/tests/test_views.py | 14 +-- .../transformers/tests/test_block_counts.py | 6 +- lms/djangoapps/course_api/tests/test_api.py | 2 +- lms/djangoapps/course_api/tests/test_views.py | 20 ++-- .../transformers/tests/helpers.py | 4 +- .../tests/test_library_content.py | 2 +- .../transformers/tests/test_split_test.py | 2 +- .../tests/test_user_partitions.py | 4 +- lms/djangoapps/course_wiki/tests/tests.py | 4 +- .../courseware/tests/test_access.py | 2 +- .../courseware/tests/test_course_survey.py | 10 +- .../courseware/tests/test_courses.py | 16 +-- .../tests/test_discussion_xblock.py | 10 +- .../courseware/tests/test_model_data.py | 58 +++++----- .../courseware/tests/test_module_render.py | 52 ++++----- .../tests/test_submitting_problems.py | 4 +- lms/djangoapps/courseware/tests/test_tabs.py | 38 +++---- .../courseware/tests/test_word_cloud.py | 2 +- lms/djangoapps/courseware/tests/tests.py | 2 +- .../coursewarehistoryextended/tests.py | 32 +++--- .../commands/tests/test_git_add_course.py | 2 +- .../dashboard/tests/test_sysadmin.py | 2 +- .../discussion/notification_prefs/tests.py | 2 +- lms/djangoapps/discussion/tests/test_views.py | 42 ++++---- .../email_marketing/tests/test_signals.py | 26 ++--- .../gating/tests/test_integration.py | 4 +- .../grades/tests/integration/test_problems.py | 6 +- lms/djangoapps/grades/tests/test_api.py | 4 +- .../grades/tests/test_course_data.py | 12 +-- .../grades/tests/test_course_grade_factory.py | 4 +- lms/djangoapps/grades/tests/test_scores.py | 20 ++-- lms/djangoapps/grades/tests/test_tasks.py | 8 +- lms/djangoapps/instructor/tests/test_api.py | 96 ++++++++--------- .../instructor/tests/test_certificates.py | 70 ++++++------ .../instructor/tests/test_enrollment.py | 2 +- lms/djangoapps/instructor/tests/test_tools.py | 6 +- .../tests/views/test_instructor_dashboard.py | 2 +- .../instructor_task/tests/test_api.py | 12 +-- .../instructor_task/tests/test_integration.py | 6 +- .../instructor_task/tests/test_tasks.py | 62 +++++------ .../tests/test_tasks_helper.py | 36 +++---- .../instructor_task/tests/test_views.py | 94 ++++++++-------- .../mobile_api/course_info/tests.py | 4 +- .../mobile_api/tests/test_decorator.py | 2 +- .../mobile_api/tests/test_middleware.py | 10 +- lms/djangoapps/mobile_api/users/tests.py | 4 +- .../program_enrollments/tests/test_models.py | 8 +- .../shoppingcart/tests/test_models.py | 50 ++++----- .../shoppingcart/tests/test_views.py | 100 +++++++++--------- lms/djangoapps/survey/tests/test_models.py | 52 ++++----- lms/djangoapps/survey/tests/test_views.py | 18 ++-- .../tests/test_reindex_course_team.py | 8 +- lms/djangoapps/teams/tests/test_views.py | 6 +- .../tests/test_manual_verify_student.py | 4 +- .../test_send_verification_expiry_email.py | 4 +- .../verify_student/tests/test_views.py | 8 +- .../tests/test_generate_course_blocks.py | 2 +- .../tests/test_block_structure.py | 30 +++--- .../block_structure/tests/test_signals.py | 2 +- .../tests/test_transformers.py | 4 +- .../tests/test_generate_course_overview.py | 8 +- .../tests/test_course_overviews.py | 2 +- .../contentserver/test/test_contentserver.py | 10 +- .../cors_csrf/tests/test_authentication.py | 2 +- .../course_groups/tests/test_cohorts.py | 32 +++--- .../tests/test_partition_scheme.py | 6 +- openedx/core/djangoapps/dark_lang/tests.py | 4 +- .../djangoapps/embargo/tests/test_forms.py | 8 +- .../djangoapps/embargo/tests/test_models.py | 12 +-- .../djangoapps/enrollments/tests/test_api.py | 52 ++++----- .../enrollments/tests/test_views.py | 4 +- .../header_control/tests/test_middleware.py | 16 +-- .../lang_pref/tests/test_middleware.py | 2 +- .../djangoapps/lang_pref/tests/test_views.py | 4 +- .../models/tests/test_course_details.py | 2 +- .../safe_sessions/tests/test_middleware.py | 22 ++-- .../tests/test_safe_cookie_data.py | 2 +- .../safe_sessions/tests/test_utils.py | 2 +- .../tests/test_create_site_configuration.py | 4 +- .../djangoapps/theming/tests/test_views.py | 4 +- .../user_api/accounts/tests/test_views.py | 2 +- .../tests/test_email_opt_in_list.py | 6 +- .../user_api/preferences/tests/test_views.py | 4 +- .../user_api/tests/test_middleware.py | 6 +- .../djangoapps/user_api/tests/test_models.py | 18 ++-- .../user_api/tests/test_partition_schemes.py | 4 +- .../djangoapps/user_api/tests/test_views.py | 4 +- .../user_authn/views/tests/test_login.py | 8 +- .../user_authn/views/tests/test_register.py | 6 +- .../views/tests/test_reset_password.py | 20 ++-- .../util/tests/test_user_messages.py | 8 +- .../tests/test_partition_scheme.py | 2 +- openedx/core/djangolib/tests/test_js_utils.py | 8 +- openedx/core/lib/tests/test_courses.py | 4 +- openedx/core/lib/tests/test_url_utils.py | 2 +- .../announcements/tests/test_announcements.py | 4 +- .../content_type_gating/tests/test_access.py | 6 +- .../enterprise_support/tests/test_api.py | 2 +- pavelib/paver_tests/test_i18n.py | 6 +- pavelib/paver_tests/test_js_test.py | 2 +- pavelib/paver_tests/test_prereqs.py | 6 +- pavelib/paver_tests/test_servers.py | 10 +- pavelib/paver_tests/test_timer.py | 40 +++---- scripts/xsslint/tests/test_main.py | 2 +- 214 files changed, 1437 insertions(+), 1437 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py index d9e90d57ee..739fe9315e 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py @@ -27,7 +27,7 @@ class TestArgParsing(TestCase): errstring = "Error: too few arguments" else: errstring = "Error: the following arguments are required: modulestore, user, org, number, run" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('create_course') def test_invalid_store(self): @@ -36,12 +36,12 @@ class TestArgParsing(TestCase): def test_nonexistent_user_id(self): errstring = "No user 99 found" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('create_course', "split", "99", "org", "course", "run") def test_nonexistent_user_email(self): errstring = "No user fake@example.com found" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('create_course', "mongo", "fake@example.com", "org", "course", "run") diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py b/cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py index d5b915a7c8..5d47a2ec44 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py @@ -25,13 +25,13 @@ class DeleteCourseTests(ModuleStoreTestCase): def test_invalid_course_key(self): course_run_key = 'foo/TestX/TS01/2015_Q7' expected_error_message = 'Invalid course_key: ' + course_run_key - with self.assertRaisesRegexp(CommandError, expected_error_message): + with self.assertRaisesRegex(CommandError, expected_error_message): call_command('delete_course', course_run_key) def test_course_not_found(self): course_run_key = 'TestX/TS01/2015_Q7' expected_error_message = 'Course not found: ' + course_run_key - with self.assertRaisesRegexp(CommandError, expected_error_message): + with self.assertRaisesRegex(CommandError, expected_error_message): call_command('delete_course', course_run_key) def test_asset_and_course_deletion(self): diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_delete_orphans.py b/cms/djangoapps/contentstore/management/commands/tests/test_delete_orphans.py index 8d4dbf720e..cf5609ef50 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_delete_orphans.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_delete_orphans.py @@ -25,7 +25,7 @@ class TestDeleteOrphan(TestOrphanBase): errstring = 'Error: too few arguments' else: errstring = 'Error: the following arguments are required: course_id' - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('delete_orphans') @ddt.data(ModuleStoreEnum.Type.split, ModuleStoreEnum.Type.mongo) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_export.py b/cms/djangoapps/contentstore/management/commands/tests/test_export.py index 4e02926125..fb50c8800b 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_export.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_export.py @@ -29,7 +29,7 @@ class TestArgParsingCourseExport(unittest.TestCase): errstring = "Error: too few arguments" else: errstring = "Error: the following arguments are required: course_id, output_path" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('export') @@ -62,7 +62,7 @@ class TestCourseExport(ModuleStoreTestCase): ) # Test `export` management command with invalid course_id errstring = "Invalid course_key: 'InvalidCourseID'." - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('export', "InvalidCourseID", self.temp_dir_1) # Test `export` management command with correct course_id @@ -74,5 +74,5 @@ class TestCourseExport(ModuleStoreTestCase): Test export command with a valid course key that doesn't exist """ errstring = "Course with x/y/z key not found." - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('export', "x/y/z", self.temp_dir_1) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py b/cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py index b950f89ce0..e1cdec7d97 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py @@ -33,7 +33,7 @@ class TestArgParsingCourseExportOlx(unittest.TestCase): errstring = "Error: too few arguments" else: errstring = "Error: the following arguments are required: course_id" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('export_olx') @@ -48,7 +48,7 @@ class TestCourseExportOlx(ModuleStoreTestCase): Test export command with an invalid course key. """ errstring = "Unparsable course_id" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('export_olx', 'InvalidCourseID') def test_course_key_not_found(self): @@ -56,7 +56,7 @@ class TestCourseExportOlx(ModuleStoreTestCase): Test export command with a valid course key that doesn't exist. """ errstring = "Invalid course_id" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('export_olx', 'x/y/z') def create_dummy_course(self, store_type): diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_fix_not_found.py b/cms/djangoapps/contentstore/management/commands/tests/test_fix_not_found.py index 4902606b70..51680dd785 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_fix_not_found.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_fix_not_found.py @@ -25,7 +25,7 @@ class TestFixNotFound(ModuleStoreTestCase): else: msg = "Error: the following arguments are required: course_id" - with self.assertRaisesRegexp(CommandError, msg): + with self.assertRaisesRegex(CommandError, msg): call_command('fix_not_found') def test_fix_not_found_non_split(self): @@ -33,7 +33,7 @@ class TestFixNotFound(ModuleStoreTestCase): The management command doesn't work on non split courses """ course = CourseFactory.create(default_store=ModuleStoreEnum.Type.mongo) - with self.assertRaisesRegexp(CommandError, "The owning modulestore does not support this command."): + with self.assertRaisesRegex(CommandError, "The owning modulestore does not support this command."): call_command("fix_not_found", six.text_type(course.id)) def test_fix_not_found(self): diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_force_publish.py b/cms/djangoapps/contentstore/management/commands/tests/test_force_publish.py index 600deaba86..fb1cccc87c 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_force_publish.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_force_publish.py @@ -34,7 +34,7 @@ class TestForcePublish(SharedModuleStoreTestCase): else: errstring = "Error: the following arguments are required: course_key" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('force_publish') def test_invalid_course_key(self): @@ -42,7 +42,7 @@ class TestForcePublish(SharedModuleStoreTestCase): Test 'force_publish' command with invalid course key """ errstring = "Invalid course key." - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('force_publish', 'TestX/TS01') def test_too_many_arguments(self): @@ -50,7 +50,7 @@ class TestForcePublish(SharedModuleStoreTestCase): Test 'force_publish' command with more than 2 arguments """ errstring = "Error: unrecognized arguments: invalid-arg" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('force_publish', six.text_type(self.course.id), '--commit', 'invalid-arg') def test_course_key_not_found(self): @@ -58,7 +58,7 @@ class TestForcePublish(SharedModuleStoreTestCase): Test 'force_publish' command with non-existing course key """ errstring = "Course not found." - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('force_publish', six.text_type('course-v1:org+course+run')) def test_force_publish_non_split(self): @@ -67,7 +67,7 @@ class TestForcePublish(SharedModuleStoreTestCase): """ course = CourseFactory.create(default_store=ModuleStoreEnum.Type.mongo) errstring = 'The owning modulestore does not support this command.' - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('force_publish', six.text_type(course.id)) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_generate_courses.py b/cms/djangoapps/contentstore/management/commands/tests/test_generate_courses.py index 9d2e560dd4..7d02880d56 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_generate_courses.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_generate_courses.py @@ -43,7 +43,7 @@ class TestGenerateCourses(ModuleStoreTestCase): """ Test that providing an invalid JSON object will result in the appropriate command error """ - with self.assertRaisesRegexp(CommandError, "Invalid JSON object"): + with self.assertRaisesRegex(CommandError, "Invalid JSON object"): arg = "invalid_json" call_command("generate_courses", arg) @@ -51,7 +51,7 @@ class TestGenerateCourses(ModuleStoreTestCase): """ Test that a missing list of courses in json will result in the appropriate command error """ - with self.assertRaisesRegexp(CommandError, "JSON object is missing courses list"): + with self.assertRaisesRegex(CommandError, "JSON object is missing courses list"): settings = {} arg = json.dumps(settings) call_command("generate_courses", arg) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py index 3b4fe60ae2..88940ace83 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py @@ -59,7 +59,7 @@ class TestGitExport(CourseTestCase): Test that the command interface works. Ignore stderr for clean test output. """ - with self.assertRaisesRegexp(CommandError, 'Error: unrecognized arguments:*'): + with self.assertRaisesRegex(CommandError, 'Error: unrecognized arguments:*'): call_command('git_export', 'blah', 'blah', 'blah', stderr=StringIO()) if six.PY2: @@ -73,23 +73,23 @@ class TestGitExport(CourseTestCase): call_command('git_export', stderr=StringIO()) # Send bad url to get course not exported - with self.assertRaisesRegexp(CommandError, six.text_type(GitExportError.URL_BAD)): + with self.assertRaisesRegex(CommandError, six.text_type(GitExportError.URL_BAD)): call_command('git_export', 'foo/bar/baz', 'silly', stderr=StringIO()) # Send bad course_id to get course not exported - with self.assertRaisesRegexp(CommandError, six.text_type(GitExportError.BAD_COURSE)): + with self.assertRaisesRegex(CommandError, six.text_type(GitExportError.BAD_COURSE)): call_command('git_export', 'foo/bar:baz', 'silly', stderr=StringIO()) def test_error_output(self): """ Verify that error output is actually resolved as the correct string """ - with self.assertRaisesRegexp(CommandError, six.text_type(GitExportError.BAD_COURSE)): + with self.assertRaisesRegex(CommandError, six.text_type(GitExportError.BAD_COURSE)): call_command( 'git_export', 'foo/bar:baz', 'silly' ) - with self.assertRaisesRegexp(CommandError, six.text_type(GitExportError.URL_BAD)): + with self.assertRaisesRegex(CommandError, six.text_type(GitExportError.URL_BAD)): call_command( 'git_export', 'foo/bar/baz', 'silly' ) @@ -99,13 +99,13 @@ class TestGitExport(CourseTestCase): Test several bad URLs for validation """ course_key = CourseLocator('org', 'course', 'run') - with self.assertRaisesRegexp(GitExportError, six.text_type(GitExportError.URL_BAD)): + with self.assertRaisesRegex(GitExportError, six.text_type(GitExportError.URL_BAD)): git_export_utils.export_to_git(course_key, 'Sillyness') - with self.assertRaisesRegexp(GitExportError, six.text_type(GitExportError.URL_BAD)): + with self.assertRaisesRegex(GitExportError, six.text_type(GitExportError.URL_BAD)): git_export_utils.export_to_git(course_key, 'example.com:edx/notreal') - with self.assertRaisesRegexp(GitExportError, + with self.assertRaisesRegex(GitExportError, six.text_type(GitExportError.URL_NO_AUTH)): git_export_utils.export_to_git(course_key, 'http://blah') @@ -117,7 +117,7 @@ class TestGitExport(CourseTestCase): self.assertFalse(os.path.isdir(test_repo_path)) course_key = CourseLocator('foo', 'blah', '100-') # Test bad clones - with self.assertRaisesRegexp(GitExportError, + with self.assertRaisesRegex(GitExportError, six.text_type(GitExportError.CANNOT_PULL)): git_export_utils.export_to_git( course_key, @@ -125,14 +125,14 @@ class TestGitExport(CourseTestCase): self.assertFalse(os.path.isdir(test_repo_path)) # Setup good repo with bad course to test xml export - with self.assertRaisesRegexp(GitExportError, + with self.assertRaisesRegex(GitExportError, six.text_type(GitExportError.XML_EXPORT_FAIL)): git_export_utils.export_to_git( course_key, 'file://{0}'.format(self.bare_repo_dir)) # Test bad git remote after successful clone - with self.assertRaisesRegexp(GitExportError, + with self.assertRaisesRegex(GitExportError, six.text_type(GitExportError.CANNOT_PULL)): git_export_utils.export_to_git( course_key, @@ -189,7 +189,7 @@ class TestGitExport(CourseTestCase): 'file://{0}'.format(self.bare_repo_dir) ) - with self.assertRaisesRegexp(GitExportError, + with self.assertRaisesRegex(GitExportError, six.text_type(GitExportError.CANNOT_COMMIT)): git_export_utils.export_to_git( self.course.id, 'file://{0}'.format(self.bare_repo_dir)) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py index 9ed7bf52e7..dd35bb7bb0 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py @@ -30,7 +30,7 @@ class TestArgParsing(TestCase): errstring = "Error: too few arguments" else: errstring = "Error: the following arguments are required: course_key, email" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command("migrate_to_split") def test_invalid_location(self): @@ -38,7 +38,7 @@ class TestArgParsing(TestCase): Test passing an unparsable course id """ errstring = "Invalid location string" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command("migrate_to_split", "foo", "bar") def test_nonexistent_user_id(self): @@ -46,7 +46,7 @@ class TestArgParsing(TestCase): Test error for using an unknown user primary key """ errstring = "No user found identified by 99" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command("migrate_to_split", "org/course/name", "99") def test_nonexistent_user_email(self): @@ -54,7 +54,7 @@ class TestArgParsing(TestCase): Test error for using an unknown user email """ errstring = "No user found identified by fake@example.com" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command("migrate_to_split", "org/course/name", "fake@example.com") diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py index d2b3c77d4a..a0f3af7799 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py @@ -69,12 +69,12 @@ class TestArgParsing(TestCase): """ def test_no_args(self): errstring = "Must specify exactly one of --course_ids, --all_courses, --from_settings" - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('migrate_transcripts') def test_invalid_course(self): errstring = "Invalid course_key: 'invalid-course'." - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('migrate_transcripts', '--course-id', 'invalid-course') diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py index 339bc5f769..d52263c6e1 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py @@ -50,25 +50,25 @@ class TestReindexCourse(ModuleStoreTestCase): def test_given_no_arguments_raises_command_error(self): """ Test that raises CommandError for incorrect arguments """ - with self.assertRaisesRegexp(CommandError, ".* requires one or more *"): + with self.assertRaisesRegex(CommandError, ".* requires one or more *"): call_command('reindex_course') @ddt.data('qwerty', 'invalid_key', 'xblockv1:qwerty') def test_given_invalid_course_key_raises_not_found(self, invalid_key): """ Test that raises InvalidKeyError for invalid keys """ err_string = u"Invalid course_key: '{0}'".format(invalid_key) - with self.assertRaisesRegexp(CommandError, err_string): + with self.assertRaisesRegex(CommandError, err_string): call_command('reindex_course', invalid_key) def test_given_library_key_raises_command_error(self): """ Test that raises CommandError if library key is passed """ - with self.assertRaisesRegexp(CommandError, ".* is not a course key"): + with self.assertRaisesRegex(CommandError, ".* is not a course key"): call_command('reindex_course', text_type(self._get_lib_key(self.first_lib))) - with self.assertRaisesRegexp(CommandError, ".* is not a course key"): + with self.assertRaisesRegex(CommandError, ".* is not a course key"): call_command('reindex_course', text_type(self._get_lib_key(self.second_lib))) - with self.assertRaisesRegexp(CommandError, ".* is not a course key"): + with self.assertRaisesRegex(CommandError, ".* is not a course key"): call_command( 'reindex_course', text_type(self.second_course.id), diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py index 88ce8753d9..8b140fdce6 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py @@ -50,7 +50,7 @@ class TestReindexLibrary(ModuleStoreTestCase): def test_given_no_arguments_raises_command_error(self): """ Test that raises CommandError for incorrect arguments """ - with self.assertRaisesRegexp(CommandError, ".* requires one or more *"): + with self.assertRaisesRegex(CommandError, ".* requires one or more *"): call_command('reindex_library') @ddt.data('qwerty', 'invalid_key', 'xblock-v1:qwe+rty') @@ -61,13 +61,13 @@ class TestReindexLibrary(ModuleStoreTestCase): def test_given_course_key_raises_command_error(self): """ Test that raises CommandError if course key is passed """ - with self.assertRaisesRegexp(CommandError, ".* is not a library key"): + with self.assertRaisesRegex(CommandError, ".* is not a library key"): call_command('reindex_library', six.text_type(self.first_course.id)) - with self.assertRaisesRegexp(CommandError, ".* is not a library key"): + with self.assertRaisesRegex(CommandError, ".* is not a library key"): call_command('reindex_library', six.text_type(self.second_course.id)) - with self.assertRaisesRegexp(CommandError, ".* is not a library key"): + with self.assertRaisesRegex(CommandError, ".* is not a library key"): call_command( 'reindex_library', six.text_type(self.second_course.id), diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_video_thumbnails.py b/cms/djangoapps/contentstore/management/commands/tests/test_video_thumbnails.py index 617b3383b2..6edfc995bd 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_video_thumbnails.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_video_thumbnails.py @@ -36,7 +36,7 @@ class TestArgParsing(TestCase): def test_invalid_course(self): errstring = "Invalid key specified: : invalid-course" setup_video_thumbnails_config(course_ids='invalid-course') - with self.assertRaisesRegexp(CommandError, errstring): + with self.assertRaisesRegex(CommandError, errstring): call_command('video_thumbnails') diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 6c156db191..66931e55a1 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -1352,7 +1352,7 @@ class ContentStoreTest(ContentStoreTestCase): resp = self.client.ajax_post('/course/', self.course_data) self.assertEqual(resp.status_code, 200) data = parse_json(resp) - self.assertRegexpMatches(data['ErrMsg'], error_message) + self.assertRegex(data['ErrMsg'], error_message) if test_enrollment: # One test case involves trying to create the same course twice. Hence for that course, # the user will be enrolled. In the other cases, initially_enrolled will be False. @@ -1518,7 +1518,7 @@ class ContentStoreTest(ContentStoreTestCase): self.assertEqual(resp.status_code, 200) data = parse_json(resp) retarget = text_type(course.id.make_usage_key('chapter', 'REPLACE')).replace('REPLACE', r'([0-9]|[a-f]){3,}') - self.assertRegexpMatches(data['locator'], retarget) + self.assertRegex(data['locator'], retarget) def test_capa_module(self): """Test that a problem treats markdown specially.""" diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index 5e641dbf3f..3494fad04d 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -87,7 +87,7 @@ class CourseSettingsEncoderTest(CourseTestCase): jsondetails = json.dumps(details, cls=CourseSettingsEncoder) jsondetails = json.loads(jsondetails) - self.assertEquals(1, jsondetails['number']) + self.assertEqual(1, jsondetails['number']) self.assertEqual(jsondetails['string'], 'string') @@ -335,10 +335,10 @@ class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin): } response = self.client.post(settings_details_url, data=json.dumps(data), content_type='application/json', HTTP_ACCEPT='application/json') - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) course = modulestore().get_course(self.course.id) self.assertTrue(course.entrance_exam_enabled) - self.assertEquals(course.entrance_exam_minimum_score_pct, .60) + self.assertEqual(course.entrance_exam_minimum_score_pct, .60) # Update the entrance exam data['entrance_exam_enabled'] = "true" @@ -349,10 +349,10 @@ class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin): content_type='application/json', HTTP_ACCEPT='application/json' ) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) course = modulestore().get_course(self.course.id) self.assertTrue(course.entrance_exam_enabled) - self.assertEquals(course.entrance_exam_minimum_score_pct, .80) + self.assertEqual(course.entrance_exam_minimum_score_pct, .80) self.assertTrue(milestones_helpers.any_unfulfilled_milestones(self.course.id, self.user.id), msg='The entrance exam should be required.') @@ -366,9 +366,9 @@ class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin): HTTP_ACCEPT='application/json' ) course = modulestore().get_course(self.course.id) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) self.assertFalse(course.entrance_exam_enabled) - self.assertEquals(course.entrance_exam_minimum_score_pct, None) + self.assertEqual(course.entrance_exam_minimum_score_pct, None) self.assertFalse(milestones_helpers.any_unfulfilled_milestones(self.course.id, self.user.id), msg='The entrance exam should not be required anymore') @@ -396,12 +396,12 @@ class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin): content_type='application/json', HTTP_ACCEPT='application/json' ) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) course = modulestore().get_course(self.course.id) self.assertTrue(course.entrance_exam_enabled) # entrance_exam_minimum_score_pct is not present in the request so default value should be saved. - self.assertEquals(course.entrance_exam_minimum_score_pct, .5) + self.assertEqual(course.entrance_exam_minimum_score_pct, .5) #add entrance_exam_minimum_score_pct with empty value in json request. test_data_2 = { @@ -422,10 +422,10 @@ class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin): content_type='application/json', HTTP_ACCEPT='application/json' ) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) course = modulestore().get_course(self.course.id) self.assertTrue(course.entrance_exam_enabled) - self.assertEquals(course.entrance_exam_minimum_score_pct, .5) + self.assertEqual(course.entrance_exam_minimum_score_pct, .5) def test_editable_short_description_fetch(self): settings_details_url = get_url(self.course.id) diff --git a/cms/djangoapps/contentstore/tests/test_crud.py b/cms/djangoapps/contentstore/tests/test_crud.py index 86db5dd30c..403ae92e47 100644 --- a/cms/djangoapps/contentstore/tests/test_crud.py +++ b/cms/djangoapps/contentstore/tests/test_crud.py @@ -39,8 +39,8 @@ class TemplateTests(ModuleStoreTestCase): self.assertIsNotNone(dropdown) self.assertIn('markdown', dropdown['metadata']) self.assertIn('data', dropdown) - self.assertRegexpMatches(dropdown['metadata']['markdown'], r'.*dropdown problems.*') - self.assertRegexpMatches(dropdown['data'], r'\s*\s*

.*dropdown problems.*') + self.assertRegex(dropdown['metadata']['markdown'], r'.*dropdown problems.*') + self.assertRegex(dropdown['data'], r'\s*\s*

.*dropdown problems.*') def test_get_some_templates(self): self.assertEqual(len(SequenceDescriptor.templates()), 0) diff --git a/cms/djangoapps/contentstore/tests/test_libraries.py b/cms/djangoapps/contentstore/tests/test_libraries.py index 5030deccbf..d1b268a1ea 100644 --- a/cms/djangoapps/contentstore/tests/test_libraries.py +++ b/cms/djangoapps/contentstore/tests/test_libraries.py @@ -790,7 +790,7 @@ class TestLibraryAccess(LibraryTestCase): edit_view_url = reverse_usage_url("xblock_view_handler", lib_block.location, {"view_name": STUDIO_VIEW}) resp = self.client.get_json(edit_view_url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) return parse_json(resp)['html'] @@ -804,7 +804,7 @@ class TestLibraryAccess(LibraryTestCase): self._login_as_non_staff_user() response = self.client.get_json(LIBRARY_REST_URL) staff_libs = parse_json(response) - self.assertEquals(2, len(staff_libs)) + self.assertEqual(2, len(staff_libs)) non_staff_settings_html = _get_settings_html() self.assertIn('staff_lib_1', non_staff_settings_html) diff --git a/cms/djangoapps/contentstore/tests/test_orphan.py b/cms/djangoapps/contentstore/tests/test_orphan.py index 92e076740a..ce81fd6fb1 100644 --- a/cms/djangoapps/contentstore/tests/test_orphan.py +++ b/cms/djangoapps/contentstore/tests/test_orphan.py @@ -236,7 +236,7 @@ class TestOrphan(TestOrphanBase): # Get parent location & verify its either of the two verticals. As both parents are non-orphan, # alphabetically least is returned html_parent = self.store.get_parent_location(html.location) - self.assertEquals(six.text_type(html_parent), six.text_type(vertical1.location)) + self.assertEqual(six.text_type(html_parent), six.text_type(vertical1.location)) # verify path_to_location returns a expected path path = path_to_location(self.store, html.location) diff --git a/cms/djangoapps/contentstore/tests/test_utils.py b/cms/djangoapps/contentstore/tests/test_utils.py index 487ab0afec..03c3378883 100644 --- a/cms/djangoapps/contentstore/tests/test_utils.py +++ b/cms/djangoapps/contentstore/tests/test_utils.py @@ -27,12 +27,12 @@ class LMSLinksTestCase(TestCase): course_key = CourseLocator('mitX', '101', 'test') location = course_key.make_usage_key('vertical', 'contacting_us') link = utils.get_lms_link_for_item(location, False) - self.assertEquals(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type" + self.assertEqual(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type" "@vertical+block@contacting_us") # test preview link = utils.get_lms_link_for_item(location, True) - self.assertEquals( + self.assertEqual( link, "//preview.localhost/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type@vertical+block" "@contacting_us " @@ -41,7 +41,7 @@ class LMSLinksTestCase(TestCase): # now test with the course' location location = course_key.make_usage_key('course', 'test') link = utils.get_lms_link_for_item(location) - self.assertEquals(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type" + self.assertEqual(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type" "@course+block@test") def lms_link_for_certificate_web_view_test(self): @@ -50,7 +50,7 @@ class LMSLinksTestCase(TestCase): dummy_user = ModuleStoreEnum.UserID.test mode = 'professional' - self.assertEquals( + self.assertEqual( utils.get_lms_link_for_certificate_web_view(dummy_user, course_key, mode), "//localhost:8000/certificates/user/{user_id}/course/{course_key}?preview={mode}".format( user_id=dummy_user, @@ -60,7 +60,7 @@ class LMSLinksTestCase(TestCase): ) with with_site_configuration_context(configuration={"course_org_filter": "mitX", "LMS_BASE": "dummyhost:8000"}): - self.assertEquals( + self.assertEqual( utils.get_lms_link_for_certificate_web_view(dummy_user, course_key, mode), "//dummyhost:8000/certificates/user/{user_id}/course/{course_key}?preview={mode}".format( user_id=dummy_user, diff --git a/cms/djangoapps/contentstore/tests/test_video_utils.py b/cms/djangoapps/contentstore/tests/test_video_utils.py index 8747bc9cef..1493677e02 100644 --- a/cms/djangoapps/contentstore/tests/test_video_utils.py +++ b/cms/djangoapps/contentstore/tests/test_video_utils.py @@ -37,7 +37,7 @@ class ValidateVideoImageTestCase(TestCase): Test that when no file information is provided to validate_video_image, it gives proper error message. """ error = validate_video_image({}) - self.assertEquals(error, 'The image must have name, content type, and size information.') + self.assertEqual(error, 'The image must have name, content type, and size information.') def test_corrupt_image_file(self): """ @@ -50,7 +50,7 @@ class ValidateVideoImageTestCase(TestCase): size=settings.VIDEO_IMAGE_SETTINGS['VIDEO_IMAGE_MIN_BYTES'] ) error = validate_video_image(uploaded_image_file) - self.assertEquals(error, 'There is a problem with this image file. Try to upload a different file.') + self.assertEqual(error, 'There is a problem with this image file. Try to upload a different file.') @ddt.ddt diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index 4d25aac60c..be0b033cc1 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -151,7 +151,7 @@ class AuthTestCase(ContentStoreTestCase): # make sure we can access courseware immediately course_url = '/home/' resp = self.client.get_html(course_url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) # then wait a bit and see if we get timed out time.sleep(2) diff --git a/cms/djangoapps/contentstore/views/tests/test_assets.py b/cms/djangoapps/contentstore/views/tests/test_assets.py index c924b9f1d2..6ed1941ca2 100644 --- a/cms/djangoapps/contentstore/views/tests/test_assets.py +++ b/cms/djangoapps/contentstore/views/tests/test_assets.py @@ -80,14 +80,14 @@ class BasicAssetsTestCase(AssetsTestCase): """ def test_basic(self): resp = self.client.get(self.url, HTTP_ACCEPT='text/html') - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) def test_static_url_generation(self): course_key = CourseLocator('org', 'class', 'run') location = course_key.make_asset_key('asset', 'my_file_name.jpg') path = StaticContent.get_static_path_from_location(location) - self.assertEquals(path, '/static/my_file_name.jpg') + self.assertEqual(path, '/static/my_file_name.jpg') def test_pdf_asset(self): module_store = modulestore() @@ -138,7 +138,7 @@ class BasicAssetsTestCase(AssetsTestCase): self.assertIn("/{}".format(filename), url) resp = self.client.get(url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) # simulation of html page where base_url is up-to asset's main directory # and relative_path is dom element with its src @@ -148,7 +148,7 @@ class BasicAssetsTestCase(AssetsTestCase): self.assertIn("/{}".format(relative_path), absolute_path) resp = self.client.get(absolute_path) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) class PaginationTestCase(AssetsTestCase): @@ -247,9 +247,9 @@ class PaginationTestCase(AssetsTestCase): resp = self.client.get(url, HTTP_ACCEPT='application/json') json_response = json.loads(resp.content.decode('utf-8')) assets_response = json_response['assets'] - self.assertEquals(json_response['start'], expected_start) - self.assertEquals(len(assets_response), expected_length) - self.assertEquals(json_response['totalCount'], expected_total) + self.assertEqual(json_response['start'], expected_start) + self.assertEqual(len(assets_response), expected_length) + self.assertEqual(json_response['totalCount'], expected_total) def assert_correct_sort_response(self, url, sort, direction): """ @@ -259,8 +259,8 @@ class PaginationTestCase(AssetsTestCase): url + '?sort=' + sort + '&direction=' + direction, HTTP_ACCEPT='application/json') json_response = json.loads(resp.content.decode('utf-8')) assets_response = json_response['assets'] - self.assertEquals(sort, json_response['sort']) - self.assertEquals(direction, json_response['direction']) + self.assertEqual(sort, json_response['sort']) + self.assertEqual(direction, json_response['direction']) name1 = assets_response[0][sort] name2 = assets_response[1][sort] name3 = assets_response[2][sort] @@ -295,7 +295,7 @@ class PaginationTestCase(AssetsTestCase): url + '?' + filter_type + '=' + filter_value, HTTP_ACCEPT='application/json') json_response = json.loads(resp.content.decode('utf-8')) assets_response = json_response['assets'] - self.assertEquals(filter_value_split, json_response['assetTypes']) + self.assertEqual(filter_value_split, json_response['assetTypes']) if filter_value != '': content_types = [asset['content_type'].lower() @@ -317,7 +317,7 @@ class PaginationTestCase(AssetsTestCase): """ resp = self.client.get( url + '?' + filter_type + '=' + filter_value, HTTP_ACCEPT='application/json') - self.assertEquals(resp.status_code, 400) + self.assertEqual(resp.status_code, 400) def assert_correct_text_search_response(self, url, text_search, number_matches): """ @@ -327,8 +327,8 @@ class PaginationTestCase(AssetsTestCase): url + '?text_search=' + text_search, HTTP_ACCEPT='application/json') json_response = json.loads(resp.content.decode('utf-8')) assets_response = json_response['assets'] - self.assertEquals(text_search, json_response['textSearch']) - self.assertEquals(len(assets_response), number_matches) + self.assertEqual(text_search, json_response['textSearch']) + self.assertEqual(len(assets_response), number_matches) text_search_tokens = text_search.split() @@ -348,15 +348,15 @@ class UploadTestCase(AssetsTestCase): def test_happy_path(self): resp = self.upload_asset() - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) def test_upload_image(self): resp = self.upload_asset("test_image", asset_type="image") - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) def test_no_file(self): resp = self.client.post(self.url, {"name": "file.txt"}, "application/json") - self.assertEquals(resp.status_code, 400) + self.assertEqual(resp.status_code, 400) @data( (int(MAX_FILE_SIZE / 2.0), "small.file.test", 200), @@ -374,7 +374,7 @@ class UploadTestCase(AssetsTestCase): "name": name, "file": f }) - self.assertEquals(resp.status_code, status_code) + self.assertEqual(resp.status_code, status_code) class DownloadTestCase(AssetsTestCase): @@ -387,19 +387,19 @@ class DownloadTestCase(AssetsTestCase): # First, upload something. self.asset_name = 'download_test' resp = self.upload_asset(self.asset_name) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.uploaded_url = json.loads(resp.content.decode('utf-8'))['asset']['url'] def test_download(self): # Now, download it. resp = self.client.get(self.uploaded_url, HTTP_ACCEPT='text/html') - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertContains(resp, 'This file is generated by python unit test') def test_download_not_found_throw(self): url = self.uploaded_url.replace(self.asset_name, 'not_the_asset_name') resp = self.client.get(url, HTTP_ACCEPT='text/html') - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) @patch('xmodule.modulestore.mixed.MixedModuleStore.find_asset_metadata') def test_pickling_calls(self, patched_find_asset_metadata): @@ -426,16 +426,16 @@ class AssetToJsonTestCase(AssetsTestCase): # pylint: disable=protected-access output = assets._get_asset_json("my_file", content_type, upload_date, location, thumbnail_location, True) - self.assertEquals(output["display_name"], "my_file") - self.assertEquals(output["date_added"], "Jun 01, 2013 at 10:30 UTC") - self.assertEquals(output["url"], "/asset-v1:org+class+run+type@asset+block@my_file_name.jpg") - self.assertEquals( + self.assertEqual(output["display_name"], "my_file") + self.assertEqual(output["date_added"], "Jun 01, 2013 at 10:30 UTC") + self.assertEqual(output["url"], "/asset-v1:org+class+run+type@asset+block@my_file_name.jpg") + self.assertEqual( output["external_url"], "lms_base_url/asset-v1:org+class+run+type@asset+block@my_file_name.jpg" ) - self.assertEquals(output["portable_url"], "/static/my_file_name.jpg") - self.assertEquals(output["thumbnail"], "/asset-v1:org+class+run+type@thumbnail+block@my_file_name_thumb.jpg") - self.assertEquals(output["id"], six.text_type(location)) - self.assertEquals(output['locked'], True) + self.assertEqual(output["portable_url"], "/static/my_file_name.jpg") + self.assertEqual(output["thumbnail"], "/asset-v1:org+class+run+type@thumbnail+block@my_file_name_thumb.jpg") + self.assertEqual(output["id"], six.text_type(location)) + self.assertEqual(output['locked'], True) output = assets._get_asset_json("name", content_type, upload_date, location, None, False) self.assertIsNone(output["thumbnail"]) @@ -513,7 +513,7 @@ class DeleteAssetTestCase(AssetsTestCase): self.asset = self.get_sample_asset(self.asset_name) response = self.client.post(self.url, {"name": self.asset_name, "file": self.asset}) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) self.uploaded_url = json.loads(response.content.decode('utf-8'))['asset']['url'] self.asset_location = AssetKey.from_string(self.uploaded_url) @@ -524,7 +524,7 @@ class DeleteAssetTestCase(AssetsTestCase): test_url = reverse_course_url( 'assets_handler', self.course.id, kwargs={'asset_key_string': six.text_type(self.uploaded_url)}) resp = self.client.delete(test_url, HTTP_ACCEPT="application/json") - self.assertEquals(resp.status_code, 204) + self.assertEqual(resp.status_code, 204) def test_delete_image_type_asset(self): """ Tests deletion of image type asset """ @@ -533,12 +533,12 @@ class DeleteAssetTestCase(AssetsTestCase): # upload image response = self.client.post(self.url, {"name": "delete_image_test", "file": image_asset}) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) uploaded_image_url = json.loads(response.content.decode('utf-8'))['asset']['url'] # upload image thumbnail response = self.client.post(self.url, {"name": "delete_image_thumb_test", "file": thumbnail_image_asset}) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) thumbnail_url = json.loads(response.content.decode('utf-8'))['asset']['url'] thumbnail_location = StaticContent.get_location_from_path(thumbnail_url) @@ -553,7 +553,7 @@ class DeleteAssetTestCase(AssetsTestCase): test_url = reverse_course_url( 'assets_handler', self.course.id, kwargs={'asset_key_string': six.text_type(uploaded_image_url)}) resp = self.client.delete(test_url, HTTP_ACCEPT="application/json") - self.assertEquals(resp.status_code, 204) + self.assertEqual(resp.status_code, 204) def test_delete_asset_with_invalid_asset(self): """ Tests the sad path :( """ @@ -562,7 +562,7 @@ class DeleteAssetTestCase(AssetsTestCase): self.course.id, kwargs={'asset_key_string': six.text_type("/c4x/edX/toy/asset/invalid.pdf")} ) resp = self.client.delete(test_url, HTTP_ACCEPT="application/json") - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) def test_delete_asset_with_invalid_thumbnail(self): """ Tests the sad path :( """ @@ -571,4 +571,4 @@ class DeleteAssetTestCase(AssetsTestCase): self.content.thumbnail_location = StaticContent.get_location_from_path('/c4x/edX/toy/asset/invalid') contentstore().save(self.content) resp = self.client.delete(test_url, HTTP_ACCEPT="application/json") - self.assertEquals(resp.status_code, 204) + self.assertEqual(resp.status_code, 204) diff --git a/cms/djangoapps/contentstore/views/tests/test_certificates.py b/cms/djangoapps/contentstore/views/tests/test_certificates.py index 9f2c54ba58..e4a0ddcbac 100644 --- a/cms/djangoapps/contentstore/views/tests/test_certificates.py +++ b/cms/djangoapps/contentstore/views/tests/test_certificates.py @@ -267,7 +267,7 @@ class CertificatesListHandlerTestCase( course_key=self.course.id, mode='honor' ) - self.assertEquals(test_link, None) + self.assertEqual(test_link, None) @override_settings(LMS_BASE="lms_base_url") def test_lms_link_for_certificate_web_view(self): @@ -278,7 +278,7 @@ class CertificatesListHandlerTestCase( course_key=self.course.id, mode='honor' ) - self.assertEquals(link, test_url) + self.assertEqual(link, test_url) @mock.patch.dict('django.conf.settings.FEATURES', {'CERTIFICATES_HTML_VIEW': True}) def test_certificate_info_in_response(self): @@ -301,7 +301,7 @@ class CertificatesListHandlerTestCase( # in JSON response response = self.client.get_json(self._url()) data = json.loads(response.content.decode('utf-8')) - self.assertEquals(len(data), 1) + self.assertEqual(len(data), 1) self.assertEqual(data[0]['name'], 'Test certificate') self.assertEqual(data[0]['description'], 'Test description') self.assertEqual(data[0]['version'], CERTIFICATE_SCHEMA_VERSION) @@ -784,7 +784,7 @@ class CertificatesDetailHandlerTestCase( HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest" ) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) course = self.store.get_course(self.course.id) certificates = course.certificates['certificates'] self.assertEqual(certificates[0].get('is_active'), is_active) @@ -812,7 +812,7 @@ class CertificatesDetailHandlerTestCase( HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest" ) - self.assertEquals(response.status_code, 403) + self.assertEqual(response.status_code, 403) @ddt.data(C4X_SIGNATORY_PATH, SIGNATORY_PATH) def test_certificate_activation_failure(self, signatory_path): @@ -831,7 +831,7 @@ class CertificatesDetailHandlerTestCase( HTTP_ACCEPT="application/json", HTTP_X_REQUESTED_WITH="XMLHttpRequest", ) - self.assertEquals(response.status_code, 403) + self.assertEqual(response.status_code, 403) course = self.store.get_course(self.course.id) certificates = course.certificates['certificates'] self.assertEqual(certificates[0].get('is_active'), False) diff --git a/cms/djangoapps/contentstore/views/tests/test_container_page.py b/cms/djangoapps/contentstore/views/tests/test_container_page.py index b9e3f82aa5..36c239a81e 100644 --- a/cms/djangoapps/contentstore/views/tests/test_container_page.py +++ b/cms/djangoapps/contentstore/views/tests/test_container_page.py @@ -112,7 +112,7 @@ class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase): """ html = self.get_page_html(xblock) self.assertIn(expected_section_tag, html) - self.assertRegexpMatches(html, re.compile(expected_breadcrumbs, re.DOTALL)) + self.assertRegex(html, re.compile(expected_breadcrumbs, re.DOTALL)) def test_public_container_preview_html(self): """ diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index 959bd5fd4f..5edfcbe020 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -178,7 +178,7 @@ class TestCourseIndex(CourseTestCase): resp = self.client.get(notification_url, HTTP_ACCEPT='application/json') # verify that we get an empty dict out - self.assertEquals(resp.status_code, 400) + self.assertEqual(resp.status_code, 400) # create a test notification rerun_state = CourseRerunState.objects.update_state( @@ -200,9 +200,9 @@ class TestCourseIndex(CourseTestCase): json_response = json.loads(resp.content.decode('utf-8')) - self.assertEquals(json_response['state'], state) - self.assertEquals(json_response['action'], action) - self.assertEquals(json_response['should_display'], should_display) + self.assertEqual(json_response['state'], state) + self.assertEqual(json_response['action'], action) + self.assertEqual(json_response['should_display'], should_display) def test_notifications_handler_dismiss(self): state = CourseRerunUIStateManager.State.FAILED @@ -230,7 +230,7 @@ class TestCourseIndex(CourseTestCase): 'action_state_id': rerun_state.id, }) resp = self.client.delete(notification_dismiss_url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) with self.assertRaises(CourseRerunState.DoesNotExist): # delete nofications that are dismissed @@ -388,7 +388,7 @@ class TestCourseIndexArchived(CourseTestCase): if org is not None: index_params['org'] = org index_response = self.client.get(index_url, index_params, HTTP_ACCEPT='text/html') - self.assertEquals(index_response.status_code, 200) + self.assertEqual(index_response.status_code, 200) parsed_html = lxml.html.fromstring(index_response.content) course_tab = parsed_html.find_class('courses') diff --git a/cms/djangoapps/contentstore/views/tests/test_import_export.py b/cms/djangoapps/contentstore/views/tests/test_import_export.py index dd63e8cda1..a6068219ba 100644 --- a/cms/djangoapps/contentstore/views/tests/test_import_export.py +++ b/cms/djangoapps/contentstore/views/tests/test_import_export.py @@ -92,16 +92,16 @@ class ImportEntranceExamTestCase(CourseTestCase, MilestonesTestCaseMixin): """ course = self.store.get_course(self.course.id) self.assertIsNotNone(course) - self.assertEquals(course.entrance_exam_enabled, False) + self.assertEqual(course.entrance_exam_enabled, False) with open(self.entrance_exam_tar, 'rb') as gtar: # pylint: disable=open-builtin args = {"name": self.entrance_exam_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) course = self.store.get_course(self.course.id) self.assertIsNotNone(course) - self.assertEquals(course.entrance_exam_enabled, True) - self.assertEquals(course.entrance_exam_minimum_score_pct, 0.7) + self.assertEqual(course.entrance_exam_enabled, True) + self.assertEqual(course.entrance_exam_minimum_score_pct, 0.7) def test_import_delete_pre_exiting_entrance_exam(self): """ @@ -129,11 +129,11 @@ class ImportEntranceExamTestCase(CourseTestCase, MilestonesTestCaseMixin): with open(self.entrance_exam_tar, 'rb') as gtar: # pylint: disable=open-builtin args = {"name": self.entrance_exam_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) course = self.store.get_course(self.course.id) self.assertIsNotNone(course) - self.assertEquals(course.entrance_exam_enabled, True) - self.assertEquals(course.entrance_exam_minimum_score_pct, 0.7) + self.assertEqual(course.entrance_exam_enabled, True) + self.assertEqual(course.entrance_exam_minimum_score_pct, 0.7) @ddt.ddt @@ -193,7 +193,7 @@ class ImportTestCase(CourseTestCase): "name": self.bad_tar, "course-data": [btar] }) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) # Check that `import_status` returns the appropriate stage (i.e., the # stage at which import failed). resp_status = self.client.get( @@ -204,7 +204,7 @@ class ImportTestCase(CourseTestCase): ) ) - self.assertEquals(json.loads(resp_status.content.decode('utf-8'))["ImportStatus"], -2) + self.assertEqual(json.loads(resp_status.content.decode('utf-8'))["ImportStatus"], -2) def test_with_coursexml(self): """ @@ -215,7 +215,7 @@ class ImportTestCase(CourseTestCase): args = {"name": self.good_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) def test_import_in_existing_course(self): """ @@ -233,7 +233,7 @@ class ImportTestCase(CourseTestCase): with open(self.good_tar, 'rb') as gtar: # pylint: disable=open-builtin args = {"name": self.good_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) course = self.store.get_course(self.course.id) self.assertIsNotNone(course) @@ -251,7 +251,7 @@ class ImportTestCase(CourseTestCase): with open(self.good_tar, 'rb') as gtar: # pylint: disable=open-builtin args = {"name": self.good_tar, "course-data": [gtar]} resp = self.client.post(self.url, args) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) # Now check that non_staff user has his same role self.assertFalse(CourseInstructorRole(self.course.id).has_user(nonstaff_user)) @@ -345,7 +345,7 @@ class ImportTestCase(CourseTestCase): with open(tarpath, 'rb') as tar: # pylint: disable=open-builtin args = {"name": tarpath, "course-data": [tar]} resp = self.client.post(self.url, args) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) resp = self.client.get( reverse_course_url( 'import_status_handler', @@ -547,7 +547,7 @@ class ExportTestCase(CourseTestCase): Get the HTML for the page. """ resp = self.client.get_html(self.url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertContains(resp, "Export My Course Content") def test_export_json_unsupported(self): @@ -555,7 +555,7 @@ class ExportTestCase(CourseTestCase): JSON is unsupported. """ resp = self.client.get(self.url, HTTP_ACCEPT='application/json') - self.assertEquals(resp.status_code, 406) + self.assertEqual(resp.status_code, 406) def test_export_async(self): """ @@ -564,11 +564,11 @@ class ExportTestCase(CourseTestCase): Return a TarFile of the successful export. """ resp = self.client.post(self.url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) resp = self.client.get(self.status_url) result = json.loads(resp.content.decode('utf-8')) status = result['ExportStatus'] - self.assertEquals(status, 3) + self.assertEqual(status, 3) self.assertIn('ExportOutput', result) output_url = result['ExportOutput'] resp = self.client.get(output_url) @@ -582,7 +582,7 @@ class ExportTestCase(CourseTestCase): def _verify_export_succeeded(self, resp): """ Export success helper method. """ - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) self.assertTrue(resp.get('Content-Disposition').startswith('attachment')) def test_unknown_xblock_top_level(self): @@ -673,9 +673,9 @@ class ExportTestCase(CourseTestCase): def _verify_export_failure(self, expected_text): """ Export failure helper method. """ resp = self.client.post(self.url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) resp = self.client.get(self.status_url) - self.assertEquals(resp.status_code, 200) + self.assertEqual(resp.status_code, 200) result = json.loads(resp.content.decode('utf-8')) self.assertNotIn('ExportOutput', result) self.assertIn('ExportError', result) @@ -739,7 +739,7 @@ class ExportTestCase(CourseTestCase): Export failure if course does not exist """ resp = self.client.get_html(url) - self.assertEquals(resp.status_code, 404) + self.assertEqual(resp.status_code, 404) def test_non_course_author(self): """ @@ -963,7 +963,7 @@ class TestCourseExportImport(LibraryTestCase): source_course_lib_children = self.get_lib_content_block_children(source_course_location) dest_course_lib_children = self.get_lib_content_block_children(dest_course_location) - self.assertEquals(len(source_course_lib_children), len(dest_course_lib_children)) + self.assertEqual(len(source_course_lib_children), len(dest_course_lib_children)) for source_child_location, dest_child_location in zip(source_course_lib_children, dest_course_lib_children): # Assert problem names on draft branch. @@ -981,7 +981,7 @@ class TestCourseExportImport(LibraryTestCase): """ source_child = self.store.get_item(source_child_location) dest_child = self.store.get_item(dest_child_location) - self.assertEquals(source_child.display_name, dest_child.display_name) + self.assertEqual(source_child.display_name, dest_child.display_name) @ddt.data(True, False) def test_library_content_on_course_export_import(self, publish_item): @@ -1079,7 +1079,7 @@ class TestCourseExportImportProblem(CourseTestCase): ' \n\n' problem_content = self.get_problem_content(course_location) - self.assertEquals(expected_problem_content, problem_content) + self.assertEqual(expected_problem_content, problem_content) def test_problem_content_on_course_export_import(self): """ diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py index 823ad4012a..e25f03b8dd 100644 --- a/cms/djangoapps/contentstore/views/tests/test_item.py +++ b/cms/djangoapps/contentstore/views/tests/test_item.py @@ -252,7 +252,7 @@ class GetItemTest(ItemTest): # Get the preview HTML and verify the View -> link is present. html, __ = self._get_container_preview(root_usage_key) self.assertIn('wrapper-xblock', html) - self.assertRegexpMatches( + self.assertRegex( html, # The instance of the wrapper class will have an auto-generated ID. Allow any # characters after wrapper. @@ -560,7 +560,7 @@ class TestCreateItem(ItemTest): # Check that its name is not None new_tab = self.get_item_from_modulestore(usage_key) - self.assertEquals(new_tab.display_name, 'Empty') + self.assertEqual(new_tab.display_name, 'Empty') class DuplicateHelper(object): @@ -960,7 +960,7 @@ class TestMoveItem(ItemTest): # Move component and verify that response contains initial index response = self._move_component(self.html_usage_key, self.vert2_usage_key) response = json.loads(response.content.decode('utf-8')) - self.assertEquals(original_index, response['source_index']) + self.assertEqual(original_index, response['source_index']) # Verify that new parent has the moved component at the last index. parent = self.get_item_from_modulestore(self.vert2_usage_key) @@ -968,12 +968,12 @@ class TestMoveItem(ItemTest): # Verify original and new index is different now. source_index = _get_source_index(self.html_usage_key, parent) - self.assertNotEquals(original_index, source_index) + self.assertNotEqual(original_index, source_index) # Undo Move to the original index, use the source index fetched from the response. response = self._move_component(self.html_usage_key, self.vert_usage_key, response['source_index']) response = json.loads(response.content.decode('utf-8')) - self.assertEquals(original_index, response['source_index']) + self.assertEqual(original_index, response['source_index']) def test_move_large_target_index(self): """ @@ -1499,7 +1499,7 @@ class TestEditItem(TestEditItemSetup): user=self.user ) # Both display and actual value should be None - self.assertEquals(xblock_info['due_date'], u'') + self.assertEqual(xblock_info['due_date'], u'') self.assertIsNone(xblock_info['due']) def test_update_generic_fields(self): @@ -2174,7 +2174,7 @@ class TestComponentHandler(TestCase): def test_request_method(self, method): def check_handler(handler, request, suffix): - self.assertEquals(request.method, method) + self.assertEqual(request.method, method) return Response() self.descriptor.handle = check_handler @@ -2193,7 +2193,7 @@ class TestComponentHandler(TestCase): self.descriptor.handle = create_response - self.assertEquals(component_handler(self.request, self.usage_key_string, 'dummy_handler').status_code, + self.assertEqual(component_handler(self.request, self.usage_key_string, 'dummy_handler').status_code, status_code) @ddt.data((True, True), (False, False),) diff --git a/cms/djangoapps/contentstore/views/tests/test_preview.py b/cms/djangoapps/contentstore/views/tests/test_preview.py index 4aa284ecd9..8033e23ae1 100644 --- a/cms/djangoapps/contentstore/views/tests/test_preview.py +++ b/cms/djangoapps/contentstore/views/tests/test_preview.py @@ -62,13 +62,13 @@ class GetPreviewHtmlTestCase(ModuleStoreTestCase): html_pattern = re.escape( six.text_type(course.id.make_usage_key('html', 'replaceme')) ).replace('replaceme', r'html_[0-9]*') - self.assertRegexpMatches( + self.assertRegex( html, 'data-usage-id="{}"'.format(html_pattern) ) - self.assertRegexpMatches(html, 'foobar') - self.assertRegexpMatches(html, r"data-block-type=[\"\']test_aside[\"\']") - self.assertRegexpMatches(html, "Aside rendered") + self.assertRegex(html, 'foobar') + self.assertRegex(html, r"data-block-type=[\"\']test_aside[\"\']") + self.assertRegex(html, "Aside rendered") # Now ensure the acid_aside is not in the result self.assertNotRegexpMatches(html, r"data-block-type=[\"\']acid_aside[\"\']") diff --git a/cms/djangoapps/contentstore/views/tests/test_tabs.py b/cms/djangoapps/contentstore/views/tests/test_tabs.py index 87bf42d609..9bfba7260a 100644 --- a/cms/djangoapps/contentstore/views/tests/test_tabs.py +++ b/cms/djangoapps/contentstore/views/tests/test_tabs.py @@ -208,13 +208,13 @@ class PrimitiveTabEdit(ModuleStoreTestCase): tabs.primitive_delete(course, 2) self.assertNotIn({u'type': u'textbooks'}, course.tabs) # Check that discussion has shifted up - self.assertEquals(course.tabs[2], {'type': 'discussion', 'name': 'Discussion'}) + self.assertEqual(course.tabs[2], {'type': 'discussion', 'name': 'Discussion'}) def test_insert(self): """Test primitive tab insertion.""" course = CourseFactory.create() tabs.primitive_insert(course, 2, 'pdf_textbooks', 'aname') - self.assertEquals(course.tabs[2], {'type': 'pdf_textbooks', 'name': 'aname'}) + self.assertEqual(course.tabs[2], {'type': 'pdf_textbooks', 'name': 'aname'}) with self.assertRaises(ValueError): tabs.primitive_insert(course, 0, 'pdf_textbooks', 'aname') with self.assertRaises(ValueError): @@ -225,4 +225,4 @@ class PrimitiveTabEdit(ModuleStoreTestCase): course = CourseFactory.create() tabs.primitive_insert(course, 3, 'pdf_textbooks', 'aname') course2 = modulestore().get_course(course.id) - self.assertEquals(course2.tabs[3], {'type': 'pdf_textbooks', 'name': 'aname'}) + self.assertEqual(course2.tabs[3], {'type': 'pdf_textbooks', 'name': 'aname'}) diff --git a/cms/djangoapps/contentstore/views/tests/test_videos.py b/cms/djangoapps/contentstore/views/tests/test_videos.py index a851aac47d..47d7b86ea8 100644 --- a/cms/djangoapps/contentstore/views/tests/test_videos.py +++ b/cms/djangoapps/contentstore/views/tests/test_videos.py @@ -324,7 +324,7 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase): def test_get_html(self): response = self.client.get(self.url) self.assertEqual(response.status_code, 200) - self.assertRegexpMatches(response["Content-Type"], "^text/html(;.*)?$") + self.assertRegex(response["Content-Type"], "^text/html(;.*)?$") self.assertContains(response, _get_default_video_image_url()) # Crude check for presence of data in returned HTML for video in self.previous_uploads: diff --git a/cms/djangoapps/course_creators/tests/test_admin.py b/cms/djangoapps/course_creators/tests/test_admin.py index 73dd089723..12fd87ca8d 100644 --- a/cms/djangoapps/course_creators/tests/test_admin.py +++ b/cms/djangoapps/course_creators/tests/test_admin.py @@ -110,20 +110,20 @@ class CourseCreatorAdminTest(TestCase): if expect_sent_to_admin: context = {'user_name': u'test_user', 'user_email': u'test_user+courses@edx.org'} - self.assertEquals(base_num_emails + 1, len(mail.outbox), 'Expected admin message to be sent') + self.assertEqual(base_num_emails + 1, len(mail.outbox), 'Expected admin message to be sent') sent_mail = mail.outbox[base_num_emails] - self.assertEquals( + self.assertEqual( mock_render_to_string('emails/course_creator_admin_subject.txt', context), sent_mail.subject ) - self.assertEquals( + self.assertEqual( mock_render_to_string('emails/course_creator_admin_user_pending.txt', context), sent_mail.body ) - self.assertEquals(self.studio_request_email, sent_mail.from_email) + self.assertEqual(self.studio_request_email, sent_mail.from_email) self.assertEqual([self.studio_request_email], sent_mail.to) else: - self.assertEquals(base_num_emails, len(mail.outbox)) + self.assertEqual(base_num_emails, len(mail.outbox)) with mock.patch.dict('django.conf.settings.FEATURES', self.enable_creator_group_patch): # E-mail message should be sent to admin only when new state is PENDING, regardless of what @@ -171,10 +171,10 @@ class CourseCreatorAdminTest(TestCase): # login attempts in one 5 minute period before the rate gets limited for _ in range(30): response = self.client.post('/admin/login/', post_params) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) response = self.client.post('/admin/login/', post_params) # Since we are using the default rate limit behavior, we are # expecting this to return a 403 error to indicate that there have # been too many attempts - self.assertEquals(response.status_code, 403) + self.assertEqual(response.status_code, 403) diff --git a/cms/djangoapps/maintenance/tests.py b/cms/djangoapps/maintenance/tests.py index d6719adbd6..a87fd114a0 100644 --- a/cms/djangoapps/maintenance/tests.py +++ b/cms/djangoapps/maintenance/tests.py @@ -312,7 +312,7 @@ class TestAnnouncementsViews(MaintenanceViewTestCase): self.assertContains(response, '

') self.client.post(url, {"content": "Test Edit Announcement", "active": True}) announcement = Announcement.objects.get(pk=announcement.pk) - self.assertEquals(announcement.content, "Test Edit Announcement") + self.assertEqual(announcement.content, "Test Edit Announcement") def test_delete(self): """ diff --git a/cms/lib/xblock/tagging/test.py b/cms/lib/xblock/tagging/test.py index f0b9c5e034..09cd2ab25b 100644 --- a/cms/lib/xblock/tagging/test.py +++ b/cms/lib/xblock/tagging/test.py @@ -129,7 +129,7 @@ class StructuredTagsAsideTestCase(ModuleStoreTestCase): runtime = TestRuntime(services={'field-data': field_data}) xblock_aside = StructuredTagsAside(scope_ids=sids, runtime=runtime) available_tags = xblock_aside.get_available_tags() - self.assertEquals(len(available_tags), 2, "StructuredTagsAside should contains two tag categories") + self.assertEqual(len(available_tags), 2, "StructuredTagsAside should contains two tag categories") def test_preview_html(self): """ @@ -150,36 +150,36 @@ class StructuredTagsAsideTestCase(ModuleStoreTestCase): tree = etree.parse(StringIO(problem_html), parser) main_div_nodes = tree.xpath('/html/body/div/section/div') - self.assertEquals(len(main_div_nodes), 1) + self.assertEqual(len(main_div_nodes), 1) div_node = main_div_nodes[0] - self.assertEquals(div_node.get('data-init'), 'StructuredTagsInit') - self.assertEquals(div_node.get('data-runtime-class'), 'PreviewRuntime') - self.assertEquals(div_node.get('data-block-type'), 'tagging_aside') - self.assertEquals(div_node.get('data-runtime-version'), '1') + self.assertEqual(div_node.get('data-init'), 'StructuredTagsInit') + self.assertEqual(div_node.get('data-runtime-class'), 'PreviewRuntime') + self.assertEqual(div_node.get('data-block-type'), 'tagging_aside') + self.assertEqual(div_node.get('data-runtime-version'), '1') self.assertIn('xblock_asides-v1', div_node.get('class')) select_nodes = div_node.xpath("div//select[@multiple='multiple']") - self.assertEquals(len(select_nodes), 2) + self.assertEqual(len(select_nodes), 2) select_node1 = select_nodes[0] - self.assertEquals(select_node1.get('name'), self.aside_tag_dif) + self.assertEqual(select_node1.get('name'), self.aside_tag_dif) option_nodes1 = select_node1.xpath('option') - self.assertEquals(len(option_nodes1), 3) + self.assertEqual(len(option_nodes1), 3) option_values1 = [opt_elem.text for opt_elem in option_nodes1] - self.assertEquals(option_values1, ['Easy', 'Hard', 'Medium']) + self.assertEqual(option_values1, ['Easy', 'Hard', 'Medium']) select_node2 = select_nodes[1] - self.assertEquals(select_node2.get('name'), self.aside_tag_lo) - self.assertEquals(select_node2.get('multiple'), 'multiple') + self.assertEqual(select_node2.get('name'), self.aside_tag_lo) + self.assertEqual(select_node2.get('multiple'), 'multiple') option_nodes2 = select_node2.xpath('option') - self.assertEquals(len(option_nodes2), 3) + self.assertEqual(len(option_nodes2), 3) option_values2 = [opt_elem.text for opt_elem in option_nodes2 if opt_elem.text] - self.assertEquals(option_values2, ['Learned a few things', 'Learned everything', 'Learned nothing']) + self.assertEqual(option_values2, ['Learned a few things', 'Learned everything', 'Learned nothing']) # Now ensure the acid_aside is not in the result self.assertNotRegexpMatches(problem_html, r"data-block-type=[\"\']acid_aside[\"\']") diff --git a/common/djangoapps/course_action_state/tests/test_managers.py b/common/djangoapps/course_action_state/tests/test_managers.py index f0664edebe..48b6200259 100644 --- a/common/djangoapps/course_action_state/tests/test_managers.py +++ b/common/djangoapps/course_action_state/tests/test_managers.py @@ -161,4 +161,4 @@ class TestCourseActionUIStateManager(TestCourseActionStateManagerBase): source_course_key=source_course_key, ) found_action_state = CourseRerunState.objects.find_first(course_key=destination_course_key) - self.assertEquals(source_course_key, found_action_state.source_course_key) + self.assertEqual(source_course_key, found_action_state.source_course_key) diff --git a/common/djangoapps/course_modes/tests/test_views.py b/common/djangoapps/course_modes/tests/test_views.py index b20d8e3d9a..8af3b70937 100644 --- a/common/djangoapps/course_modes/tests/test_views.py +++ b/common/djangoapps/course_modes/tests/test_views.py @@ -100,7 +100,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest else: self.assertRedirects(response, reverse('dashboard')) else: - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) def test_no_id_redirect(self): # Create the course modes @@ -174,7 +174,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest follow=False, ) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) # TODO: Fix it so that response.templates works w/ mako templates, and then assert # that the right template rendered @@ -378,12 +378,12 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest url = reverse('create_mode', args=[six.text_type(self.course.id)]) response = self.client.get(url) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) expected_mode = [Mode(u'honor', u'Honor Code Certificate', 0, '', 'usd', None, None, None, None)] course_mode = CourseMode.modes_for_course(self.course.id) - self.assertEquals(course_mode, expected_mode) + self.assertEqual(course_mode, expected_mode) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') @ddt.data( @@ -402,7 +402,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest url = reverse('create_mode', args=[six.text_type(self.course.id)]) response = self.client.get(url, parameters) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) expected_mode = [ Mode( @@ -419,7 +419,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest ] course_mode = CourseMode.modes_for_course(self.course.id) - self.assertEquals(course_mode, expected_mode) + self.assertEqual(course_mode, expected_mode) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') def test_multiple_mode_creation(self): @@ -444,7 +444,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest expected_modes = [honor_mode, verified_mode] course_modes = CourseMode.modes_for_course(self.course.id) - self.assertEquals(course_modes, expected_modes) + self.assertEqual(course_modes, expected_modes) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') @with_comprehensive_theme("edx.org") diff --git a/common/djangoapps/edxmako/tests.py b/common/djangoapps/edxmako/tests.py index 2a02af33d0..5b0a44d8d6 100644 --- a/common/djangoapps/edxmako/tests.py +++ b/common/djangoapps/edxmako/tests.py @@ -31,12 +31,12 @@ class ShortcutsTests(UrlResetMixin, TestCase): with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): expected_link = 'https://dummy-root/about-us' link = marketing_link('ABOUT') - self.assertEquals(link, expected_link) + self.assertEqual(link, expected_link) # test marketing site off with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}): expected_link = reverse(self._get_test_url_name()) link = marketing_link('ABOUT') - self.assertEquals(link, expected_link) + self.assertEqual(link, expected_link) @override_settings(MKTG_URLS={'ROOT': 'https://dummy-root', 'ABOUT': '/about-us'}) def test_is_marketing_link_set(self): diff --git a/common/djangoapps/student/management/tests/test_transfer_students.py b/common/djangoapps/student/management/tests/test_transfer_students.py index 1a06dc4556..9245939937 100644 --- a/common/djangoapps/student/management/tests/test_transfer_students.py +++ b/common/djangoapps/student/management/tests/test_transfer_students.py @@ -128,9 +128,9 @@ class TestTransferStudents(ModuleStoreTestCase): self.mock_tracker.reset_mock() # Confirm the enrollment mode is verified on the new courses, and enrollment is enabled as appropriate. - self.assertEquals((mode, False), CourseEnrollment.enrollment_mode_for_user(student, course.id)) - self.assertEquals((mode, True), CourseEnrollment.enrollment_mode_for_user(student, new_course_one.id)) - self.assertEquals((mode, True), CourseEnrollment.enrollment_mode_for_user(student, new_course_two.id)) + self.assertEqual((mode, False), CourseEnrollment.enrollment_mode_for_user(student, course.id)) + self.assertEqual((mode, True), CourseEnrollment.enrollment_mode_for_user(student, new_course_one.id)) + self.assertEqual((mode, True), CourseEnrollment.enrollment_mode_for_user(student, new_course_two.id)) # Confirm the student has not be refunded. target_certs = CertificateItem.objects.filter( @@ -138,7 +138,7 @@ class TestTransferStudents(ModuleStoreTestCase): ) self.assertTrue(target_certs[0]) self.assertFalse(target_certs[0].refund_requested_time) - self.assertEquals(target_certs[0].order.status, 'purchased') + self.assertEqual(target_certs[0].order.status, 'purchased') def _create_course(self, course_location): """ diff --git a/common/djangoapps/student/tests/test_email.py b/common/djangoapps/student/tests/test_email.py index 95f5af6881..2af7a33dab 100644 --- a/common/djangoapps/student/tests/test_email.py +++ b/common/djangoapps/student/tests/test_email.py @@ -196,8 +196,8 @@ class ActivationEmailTests(EmailTemplateTagMixin, CacheIsolationTestCase): with patch('third_party_auth.is_enabled', return_value=True): reg.skip_email_verification = True inactive_user_view(request) - self.assertEquals(user.is_active, True) - self.assertEquals(email.called, False, msg='method should not have been called') + self.assertEqual(user.is_active, True) + self.assertEqual(email.called, False, msg='method should not have been called') @patch('student.tasks.log') def test_send_email_to_inactive_user(self, mock_log): @@ -258,7 +258,7 @@ class EmailChangeRequestTests(EventTestMixin, EmailTemplateTagMixin, CacheIsolat Assert that `response_data` indicates a failed request that returns `expected_error` """ self.assertFalse(response_data['success']) - self.assertEquals(expected_error, response_data['error']) + self.assertEqual(expected_error, response_data['error']) self.assertFalse(self.user.email_user.called) @patch('student.views.management.render_to_string', Mock(side_effect=mock_render_to_string, autospec=True)) @@ -298,7 +298,7 @@ class EmailChangeRequestTests(EventTestMixin, EmailTemplateTagMixin, CacheIsolat Test the return value if sending the email for the user to click fails. """ send_mail.side_effect = [Exception, None] - with self.assertRaisesRegexp(ValueError, 'Unable to send email activation link. Please try again later.'): + with self.assertRaisesRegex(ValueError, 'Unable to send email activation link. Please try again later.'): self.do_email_change(self.user, "valid@email.com") self.assert_no_events_were_emitted() @@ -399,9 +399,9 @@ class EmailChangeConfirmationTests(EmailTestMixin, EmailTemplateTagMixin, CacheI """ Assert that no changes to user, profile, or pending email have been made to the db """ - self.assertEquals(self.user.email, User.objects.get(username=self.user.username).email) - self.assertEquals(self.profile.meta, UserProfile.objects.get(user=self.user).meta) - self.assertEquals(1, PendingEmailChange.objects.count()) + self.assertEqual(self.user.email, User.objects.get(username=self.user.username).email) + self.assertEqual(self.profile.meta, UserProfile.objects.get(user=self.user).meta) + self.assertEqual(1, PendingEmailChange.objects.count()) def assertFailedBeforeEmailing(self): """ @@ -421,7 +421,7 @@ class EmailChangeConfirmationTests(EmailTestMixin, EmailTemplateTagMixin, CacheI """ response = confirm_email_change(self.request, self.key) self.assertEqual(response.status_code, 200) - self.assertEquals( + self.assertEqual( mock_render_to_response(expected_template, expected_context).content.decode('utf-8'), response.content.decode('utf-8') ) @@ -510,12 +510,12 @@ class EmailChangeConfirmationTests(EmailTestMixin, EmailTemplateTagMixin, CacheI meta = json.loads(UserProfile.objects.get(user=self.user).meta) self.assertIn('old_emails', meta) - self.assertEquals(self.user.email, meta['old_emails'][0][0]) - self.assertEquals( + self.assertEqual(self.user.email, meta['old_emails'][0][0]) + self.assertEqual( self.pending_change_request.new_email, User.objects.get(username=self.user.username).email ) - self.assertEquals(0, PendingEmailChange.objects.count()) + self.assertEqual(0, PendingEmailChange.objects.count()) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS") def test_prevent_auth_user_writes(self): @@ -579,7 +579,7 @@ class SecondaryEmailChangeRequestTests(EventTestMixin, EmailTemplateTagMixin, Ca Assert that `response_data` indicates a failed request that returns `expected_error` """ self.assertFalse(response_data['success']) - self.assertEquals(expected_error, response_data['error']) + self.assertEqual(expected_error, response_data['error']) self.assertFalse(self.user.email_user.called) def test_invalid_emails(self): @@ -596,7 +596,7 @@ class SecondaryEmailChangeRequestTests(EventTestMixin, EmailTemplateTagMixin, Ca Test the return value if sending the email for the user to click fails. """ send_mail.side_effect = [Exception, None] - with self.assertRaisesRegexp(ValueError, 'Unable to send email activation link. Please try again later.'): + with self.assertRaisesRegex(ValueError, 'Unable to send email activation link. Please try again later.'): self.do_secondary_email_change(self.user, "valid@email.com") self.assert_no_events_were_emitted() diff --git a/common/djangoapps/student/tests/test_events.py b/common/djangoapps/student/tests/test_events.py index 4145ffc487..ac460b9640 100644 --- a/common/djangoapps/student/tests/test_events.py +++ b/common/djangoapps/student/tests/test_events.py @@ -164,11 +164,11 @@ class TestUserEvents(UserSettingsEventTestMixin, TestCase): pending_enrollment = CourseEnrollmentAllowedFactory(auto_enroll=True) # the e-mail will change to test@edx.org (from something else) - self.assertNotEquals(self.user.email, 'test@edx.org') + self.assertNotEqual(self.user.email, 'test@edx.org') # there's a CEA for the new e-mail - self.assertEquals(CourseEnrollmentAllowed.objects.count(), 1) - self.assertEquals(CourseEnrollmentAllowed.objects.filter(email='test@edx.org').count(), 1) + self.assertEqual(CourseEnrollmentAllowed.objects.count(), 1) + self.assertEqual(CourseEnrollmentAllowed.objects.filter(email='test@edx.org').count(), 1) # Changing the e-mail to the enrollment-allowed e-mail should enroll self.user.email = 'test@edx.org' @@ -176,5 +176,5 @@ class TestUserEvents(UserSettingsEventTestMixin, TestCase): self.assert_user_enrollment_occurred('edX/toy/2012_Fall') # CEAs shouldn't have been affected - self.assertEquals(CourseEnrollmentAllowed.objects.count(), 1) - self.assertEquals(CourseEnrollmentAllowed.objects.filter(email='test@edx.org').count(), 1) + self.assertEqual(CourseEnrollmentAllowed.objects.count(), 1) + self.assertEqual(CourseEnrollmentAllowed.objects.filter(email='test@edx.org').count(), 1) diff --git a/common/djangoapps/student/tests/test_password_policy.py b/common/djangoapps/student/tests/test_password_policy.py index 6432cd79a7..9862e92f57 100644 --- a/common/djangoapps/student/tests/test_password_policy.py +++ b/common/djangoapps/student/tests/test_password_policy.py @@ -277,7 +277,7 @@ class TestUsernamePasswordNonmatch(TestCase): self.url_params['username'] = "foobar" self.url_params['password'] = "foobar" response = self.client.post(self.url, self.url_params) - self.assertEquals(response.status_code, 400) + self.assertEqual(response.status_code, 400) obj = json.loads(response.content.decode('utf-8')) self.assertEqual( obj['password'][0]['user_message'], @@ -291,6 +291,6 @@ class TestUsernamePasswordNonmatch(TestCase): self.url_params['username'] = "foobar" self.url_params['password'] = "nonmatch" response = self.client.post(self.url, self.url_params) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) obj = json.loads(response.content.decode('utf-8')) self.assertTrue(obj['success']) diff --git a/common/djangoapps/student/tests/test_tasks.py b/common/djangoapps/student/tests/test_tasks.py index bbebedc629..e70b028fc8 100644 --- a/common/djangoapps/student/tests/test_tasks.py +++ b/common/djangoapps/student/tests/test_tasks.py @@ -34,11 +34,11 @@ class SendActivationEmailTestCase(TestCase): """ Tests that attributes of the message are being filled correctly in compose_activation_email """ - self.assertEquals(self.msg.recipient.username, self.student.username) - self.assertEquals(self.msg.recipient.email_address, self.student.email) - self.assertEquals(self.msg.context['routed_user'], self.student.username) - self.assertEquals(self.msg.context['routed_user_email'], self.student.email) - self.assertEquals(self.msg.context['routed_profile_name'], '') + self.assertEqual(self.msg.recipient.username, self.student.username) + self.assertEqual(self.msg.recipient.email_address, self.student.email) + self.assertEqual(self.msg.context['routed_user'], self.student.username) + self.assertEqual(self.msg.context['routed_user_email'], self.student.email) + self.assertEqual(self.msg.context['routed_profile_name'], '') @mock.patch('time.sleep', mock.Mock(return_value=None)) @mock.patch('student.tasks.log') @@ -60,7 +60,7 @@ class SendActivationEmailTestCase(TestCase): attempt=attempt, max_attempts=email_max_attempts )) - self.assertEquals(mock_log.info.call_count, 6) + self.assertEqual(mock_log.info.call_count, 6) # Asserts that the error was logged on crossing max retry attempts. mock_log.error.assert_called_with( @@ -69,7 +69,7 @@ class SendActivationEmailTestCase(TestCase): self.student.email, exc_info=True ) - self.assertEquals(mock_log.error.call_count, 1) + self.assertEqual(mock_log.error.call_count, 1) @mock.patch('student.tasks.log') @mock.patch('student.tasks.ace.send', mock.Mock(side_effect=ChannelError)) @@ -90,6 +90,6 @@ class SendActivationEmailTestCase(TestCase): ) # Assert that nothing else was logged - self.assertEquals(mock_log.info.call_count, 0) - self.assertEquals(mock_log.error.call_count, 0) - self.assertEquals(mock_log.exception.call_count, 1) + self.assertEqual(mock_log.info.call_count, 0) + self.assertEqual(mock_log.error.call_count, 0) + self.assertEqual(mock_log.exception.call_count, 1) diff --git a/common/djangoapps/student/tests/test_views.py b/common/djangoapps/student/tests/test_views.py index dec1487604..664a34a419 100644 --- a/common/djangoapps/student/tests/test_views.py +++ b/common/djangoapps/student/tests/test_views.py @@ -141,13 +141,13 @@ class TestStudentDashboardUnenrollments(SharedModuleStoreTestCase): with patch('student.models.CourseEnrollment.refundable', return_value=True): response = self.client.get(reverse('course_run_refund_status', kwargs={'course_id': self.course.id})) - self.assertEquals(json.loads(response.content.decode('utf-8')), {'course_refundable_status': True}) + self.assertEqual(json.loads(response.content.decode('utf-8')), {'course_refundable_status': True}) self.assertEqual(response.status_code, 200) with patch('student.models.CourseEnrollment.refundable', return_value=False): response = self.client.get(reverse('course_run_refund_status', kwargs={'course_id': self.course.id})) - self.assertEquals(json.loads(response.content.decode('utf-8')), {'course_refundable_status': False}) + self.assertEqual(json.loads(response.content.decode('utf-8')), {'course_refundable_status': False}) self.assertEqual(response.status_code, 200) def test_course_run_refund_status_invalid_course_key(self): @@ -157,7 +157,7 @@ class TestStudentDashboardUnenrollments(SharedModuleStoreTestCase): InvalidKeyError during look up.') response = self.client.get(reverse('course_run_refund_status', kwargs={'course_id': self.course.id})) - self.assertEquals(json.loads(response.content.decode('utf-8')), {'course_refundable_status': ''}) + self.assertEqual(json.loads(response.content.decode('utf-8')), {'course_refundable_status': ''}) self.assertEqual(response.status_code, 406) diff --git a/common/djangoapps/student/tests/tests.py b/common/djangoapps/student/tests/tests.py index 1640e0f0a1..66fd7c9b78 100644 --- a/common/djangoapps/student/tests/tests.py +++ b/common/djangoapps/student/tests/tests.py @@ -386,7 +386,7 @@ class DashboardTest(ModuleStoreTestCase): enrollment = CourseEnrollment.enroll(self.user, self.course.id) course_mode_info = complete_course_mode_info(self.course.id, enrollment) self.assertTrue(course_mode_info['show_upsell']) - self.assertEquals(course_mode_info['days_for_upsell'], 1) + self.assertEqual(course_mode_info['days_for_upsell'], 1) verified_mode.expiration_datetime = datetime.now(pytz.UTC) + timedelta(days=-1) verified_mode.save() @@ -431,13 +431,13 @@ class DashboardTest(ModuleStoreTestCase): redeem_url = reverse('register_code_redemption', args=[course_reg_code.code]) response = self.client.get(redeem_url) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) # check button text self.assertContains(response, 'Activate Course Enrollment') #now activate the user by enrolling him/her to the course response = self.client.post(redeem_url) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) response = self.client.get(reverse('dashboard')) self.assertContains(response, 'You can no longer access this course because payment has not yet been received') optout_object = Optout.objects.filter(user=self.user, course_id=self.course.id) @@ -492,7 +492,7 @@ class DashboardTest(ModuleStoreTestCase): ) response = self.client.get(reverse('dashboard')) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) self.assertNotContains(response, 'Add Certificate to LinkedIn') response_url = 'http://www.linkedin.com/profile/add?_ed=' @@ -536,7 +536,7 @@ class DashboardTest(ModuleStoreTestCase): ) response = self.client.get(reverse('dashboard')) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) self.assertContains(response, 'Add Certificate to LinkedIn') expected_url = ( @@ -582,9 +582,9 @@ class DashboardTest(ModuleStoreTestCase): # CourseOverview object that has been created. with check_mongo_calls(0): response_1 = self.client.get(reverse('dashboard')) - self.assertEquals(response_1.status_code, 200) + self.assertEqual(response_1.status_code, 200) response_2 = self.client.get(reverse('dashboard')) - self.assertEquals(response_2.status_code, 200) + self.assertEqual(response_2.status_code, 200) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') def test_dashboard_header_nav_has_find_courses(self): @@ -602,7 +602,7 @@ class DashboardTest(ModuleStoreTestCase): """It will be true only if enrollment mode is honor and course has verified mode.""" course_mode_info = self._enrollment_with_complete_course('honor') self.assertTrue(course_mode_info['show_upsell']) - self.assertEquals(course_mode_info['days_for_upsell'], 1) + self.assertEqual(course_mode_info['days_for_upsell'], 1) @ddt.data('verified', 'credit') def test_course_mode_info_with_different_enrollments(self, enrollment_mode): @@ -798,11 +798,11 @@ class EnrollInCourseTest(EnrollmentEventTestMixin, CacheIsolationTestCase): # Make sure mode is updated properly if user unenrolls & re-enrolls enrollment = CourseEnrollment.enroll(user, course_id, "verified") - self.assertEquals(enrollment.mode, "verified") + self.assertEqual(enrollment.mode, "verified") CourseEnrollment.unenroll(user, course_id) enrollment = CourseEnrollment.enroll(user, course_id, "audit") self.assertTrue(CourseEnrollment.is_enrolled(user, course_id)) - self.assertEquals(enrollment.mode, "audit") + self.assertEqual(enrollment.mode, "audit") def test_enrollment_non_existent_user(self): # Testing enrollment of newly unsaved user (i.e. no database entry) diff --git a/common/djangoapps/third_party_auth/management/commands/tests/test_remove_social_auth_users.py b/common/djangoapps/third_party_auth/management/commands/tests/test_remove_social_auth_users.py index 0358a3edec..a24e920221 100644 --- a/common/djangoapps/third_party_auth/management/commands/tests/test_remove_social_auth_users.py +++ b/common/djangoapps/third_party_auth/management/commands/tests/test_remove_social_auth_users.py @@ -87,7 +87,7 @@ class TestRemoveSocialAuthUsersCommand(TestCase): def test_invalid_idp(self): invalid_slug = 'jedi-academy' err_string = u'No SAML provider found for slug {}'.format(invalid_slug) - with self.assertRaisesRegexp(CommandError, err_string): + with self.assertRaisesRegex(CommandError, err_string): call_command(self.command, invalid_slug) @override_settings(FEATURES=FEATURES_WITH_ENABLED) @@ -104,7 +104,7 @@ class TestRemoveSocialAuthUsersCommand(TestCase): @override_settings(FEATURES=FEATURES_WITH_ENABLED) def test_confirmation_failure(self): err_string = 'User confirmation required. No records have been modified' - with self.assertRaisesRegexp(CommandError, err_string): + with self.assertRaisesRegex(CommandError, err_string): with self._replace_stdin('no'): call_command(self.command, self.provider_hogwarts.slug) @@ -115,5 +115,5 @@ class TestRemoveSocialAuthUsersCommand(TestCase): def test_feature_default_disabled(self): """ By default this command should not be enabled """ err_string = 'ENABLE_ENROLLMENT_RESET feature not enabled on this enviroment' - with self.assertRaisesRegexp(CommandError, err_string): + with self.assertRaisesRegex(CommandError, err_string): call_command(self.command, self.provider_hogwarts.slug, force=True) diff --git a/common/djangoapps/third_party_auth/management/commands/tests/test_saml.py b/common/djangoapps/third_party_auth/management/commands/tests/test_saml.py index c471277f88..4f09e4f467 100644 --- a/common/djangoapps/third_party_auth/management/commands/tests/test_saml.py +++ b/common/djangoapps/third_party_auth/management/commands/tests/test_saml.py @@ -131,7 +131,7 @@ class TestSAMLCommand(TestCase): expected = "\nDone.\n1 provider(s) found in database.\n0 skipped and 1 attempted.\n0 updated and 1 failed.\n" - with self.assertRaisesRegexp(CommandError, r"HTTPError: 404 Client Error"): + with self.assertRaisesRegex(CommandError, r"HTTPError: 404 Client Error"): call_command("saml", pull=True, stdout=self.stdout) self.assertIn(expected, self.stdout.getvalue()) @@ -176,7 +176,7 @@ class TestSAMLCommand(TestCase): ) expected = '\n3 provider(s) found in database.\n0 skipped and 3 attempted.\n2 updated and 1 failed.\n' - with self.assertRaisesRegexp(CommandError, r"MetadataParseError: Can't find EntityDescriptor for entityID"): + with self.assertRaisesRegex(CommandError, r"MetadataParseError: Can't find EntityDescriptor for entityID"): call_command("saml", pull=True, stdout=self.stdout) self.assertIn(expected, self.stdout.getvalue()) @@ -199,7 +199,7 @@ class TestSAMLCommand(TestCase): # Four configurations -- one will be skipped and three attempted, with similar results. expected = '\nDone.\n4 provider(s) found in database.\n1 skipped and 3 attempted.\n0 updated and 1 failed.\n' - with self.assertRaisesRegexp(CommandError, r"MetadataParseError: Can't find EntityDescriptor for entityID"): + with self.assertRaisesRegex(CommandError, r"MetadataParseError: Can't find EntityDescriptor for entityID"): call_command("saml", pull=True, stdout=self.stdout) self.assertIn(expected, self.stdout.getvalue()) @@ -215,19 +215,19 @@ class TestSAMLCommand(TestCase): expected = "\nDone.\n1 provider(s) found in database.\n0 skipped and 1 attempted.\n0 updated and 1 failed.\n" - with self.assertRaisesRegexp(CommandError, "SSLError:"): + with self.assertRaisesRegex(CommandError, "SSLError:"): call_command("saml", pull=True, stdout=self.stdout) self.assertIn(expected, self.stdout.getvalue()) mocked_get.side_effect = exceptions.ConnectionError - with self.assertRaisesRegexp(CommandError, "ConnectionError:"): + with self.assertRaisesRegex(CommandError, "ConnectionError:"): call_command("saml", pull=True, stdout=self.stdout) self.assertIn(expected, self.stdout.getvalue()) mocked_get.side_effect = exceptions.HTTPError - with self.assertRaisesRegexp(CommandError, "HTTPError:"): + with self.assertRaisesRegex(CommandError, "HTTPError:"): call_command("saml", pull=True, stdout=self.stdout) self.assertIn(expected, self.stdout.getvalue()) @@ -252,7 +252,7 @@ class TestSAMLCommand(TestCase): expected = "\nDone.\n2 provider(s) found in database.\n1 skipped and 1 attempted.\n0 updated and 1 failed.\n" - with self.assertRaisesRegexp(CommandError, "MetadataParseError: Can't find EntityDescriptor for entityID"): + with self.assertRaisesRegex(CommandError, "MetadataParseError: Can't find EntityDescriptor for entityID"): call_command("saml", pull=True, stdout=self.stdout) self.assertIn(expected, self.stdout.getvalue()) @@ -272,6 +272,6 @@ class TestSAMLCommand(TestCase): expected = "\nDone.\n1 provider(s) found in database.\n0 skipped and 1 attempted.\n0 updated and 1 failed.\n" - with self.assertRaisesRegexp(CommandError, "XMLSyntaxError:"): + with self.assertRaisesRegex(CommandError, "XMLSyntaxError:"): call_command("saml", pull=True, stdout=self.stdout) self.assertIn(expected, self.stdout.getvalue()) diff --git a/common/djangoapps/third_party_auth/tests/test_admin.py b/common/djangoapps/third_party_auth/tests/test_admin.py index dd5985da44..f28c98e8ae 100644 --- a/common/djangoapps/third_party_auth/tests/test_admin.py +++ b/common/djangoapps/third_party_auth/tests/test_admin.py @@ -55,8 +55,8 @@ class Oauth2ProviderConfigAdminTest(testutil.TestCase): # Get the provider instance with active flag providers = OAuth2ProviderConfig.objects.all() - self.assertEquals(len(providers), 1) - self.assertEquals(providers[pcount].id, provider1.id) + self.assertEqual(len(providers), 1) + self.assertEqual(providers[pcount].id, provider1.id) # Edit the provider via the admin edit link admin = OAuth2ProviderConfigAdmin(provider1, AdminSite()) @@ -76,14 +76,14 @@ class Oauth2ProviderConfigAdminTest(testutil.TestCase): # Post the edit form: expecting redirect response = self.client.post(update_url, post_data) - self.assertEquals(response.status_code, 302) + self.assertEqual(response.status_code, 302) # Editing the existing provider creates a new provider instance providers = OAuth2ProviderConfig.objects.all() - self.assertEquals(len(providers), pcount + 2) - self.assertEquals(providers[pcount].id, provider1.id) + self.assertEqual(len(providers), pcount + 2) + self.assertEqual(providers[pcount].id, provider1.id) provider2 = providers[pcount + 1] # Ensure the icon_image was preserved on the new provider instance - self.assertEquals(provider2.icon_image, provider1.icon_image) - self.assertEquals(provider2.name, post_data['name']) + self.assertEqual(provider2.icon_image, provider1.icon_image) + self.assertEqual(provider2.name, post_data['name']) diff --git a/common/djangoapps/third_party_auth/tests/test_lti.py b/common/djangoapps/third_party_auth/tests/test_lti.py index 202a471018..1053e65ac9 100644 --- a/common/djangoapps/third_party_auth/tests/test_lti.py +++ b/common/djangoapps/third_party_auth/tests/test_lti.py @@ -22,7 +22,7 @@ class UnitTestLTI(unittest.TestCase, ThirdPartyAuthTestMixin): details = lti.get_user_details({LTI_PARAMS_KEY: { 'lis_person_name_full': 'Full name' }}) - self.assertEquals(details, { + self.assertEqual(details, { 'fullname': 'Full name' }) @@ -35,7 +35,7 @@ class UnitTestLTI(unittest.TestCase, ThirdPartyAuthTestMixin): 'email': 'user@example.com', 'other': 'something else' }}) - self.assertEquals(details, { + self.assertEqual(details, { 'fullname': 'Full name', 'first_name': 'Given', 'last_name': 'Family', @@ -48,7 +48,7 @@ class UnitTestLTI(unittest.TestCase, ThirdPartyAuthTestMixin): 'oauth_consumer_key': 'consumer', 'user_id': 'user' }}) - self.assertEquals(user_id, 'consumer:user') + self.assertEqual(user_id, 'consumer:user') def test_validate_lti_valid_request(self): request = Request( diff --git a/common/djangoapps/third_party_auth/tests/test_pipeline_integration.py b/common/djangoapps/third_party_auth/tests/test_pipeline_integration.py index 55f570c85e..2acc2d0ff5 100644 --- a/common/djangoapps/third_party_auth/tests/test_pipeline_integration.py +++ b/common/djangoapps/third_party_auth/tests/test_pipeline_integration.py @@ -82,7 +82,7 @@ class GetProviderUserStatesTestCase(testutil.TestCase, test.TestCase): def test_returns_empty_list_if_no_enabled_providers(self): self.assertFalse(provider.Registry.enabled()) - self.assertEquals([], pipeline.get_provider_user_states(self.user)) + self.assertEqual([], pipeline.get_provider_user_states(self.user)) def test_state_not_returned_for_disabled_provider(self): disabled_provider = self.configure_google_provider(enabled=False) diff --git a/common/djangoapps/track/management/tests/test_tracked_command.py b/common/djangoapps/track/management/tests/test_tracked_command.py index 11d722ac53..1d11c1c7e4 100644 --- a/common/djangoapps/track/management/tests/test_tracked_command.py +++ b/common/djangoapps/track/management/tests/test_tracked_command.py @@ -24,4 +24,4 @@ class CommandsTestBase(TestCase): args = ['whee'] kwargs = {'key1': 'default', 'key2': True} json_out = self._run_dummy_command(*args, **kwargs) - self.assertEquals(json_out['command'].strip(), 'tracked_dummy_command') + self.assertEqual(json_out['command'].strip(), 'tracked_dummy_command') diff --git a/common/djangoapps/track/tests/__init__.py b/common/djangoapps/track/tests/__init__.py index 787c05d751..10e8ed32f6 100644 --- a/common/djangoapps/track/tests/__init__.py +++ b/common/djangoapps/track/tests/__init__.py @@ -73,7 +73,7 @@ class EventTrackingTestCase(TestCase): def assert_no_events_emitted(self): """Ensure no events were emitted at this point in the test.""" - self.assertEquals(len(self.backend.events), 0) + self.assertEqual(len(self.backend.events), 0) def assert_events_emitted(self): """Ensure at least one event has been emitted at this point in the test.""" diff --git a/common/djangoapps/track/tests/test_contexts.py b/common/djangoapps/track/tests/test_contexts.py index 584a6fe82b..9247a78ce7 100644 --- a/common/djangoapps/track/tests/test_contexts.py +++ b/common/djangoapps/track/tests/test_contexts.py @@ -30,7 +30,7 @@ class TestContexts(TestCase): self.assert_parses_course_id_from_url(url, course_id) def assert_parses_course_id_from_url(self, format_string, course_id): - self.assertEquals( + self.assertEqual( contexts.course_context_from_url(format_string.format(course_id=course_id)), { 'course_id': course_id, @@ -42,7 +42,7 @@ class TestContexts(TestCase): self.assert_empty_context_for_url('http://foo.bar.com/dashboard') def assert_empty_context_for_url(self, url): - self.assertEquals( + self.assertEqual( contexts.course_context_from_url(url), { 'course_id': '', diff --git a/common/djangoapps/track/views/tests/test_segmentio.py b/common/djangoapps/track/views/tests/test_segmentio.py index c67d9b1a95..580c8d77e3 100644 --- a/common/djangoapps/track/views/tests/test_segmentio.py +++ b/common/djangoapps/track/views/tests/test_segmentio.py @@ -19,7 +19,7 @@ def expect_failure_with_message(message): """Ensure the test raises an exception and does not emit an event""" def test_decorator(func): def test_decorated(self, *args, **kwargs): - self.assertRaisesRegexp(segmentio.EventValidationError, message, func, self, *args, **kwargs) + self.assertRaisesRegex(segmentio.EventValidationError, message, func, self, *args, **kwargs) self.assert_no_events_emitted() return test_decorated return test_decorator @@ -39,7 +39,7 @@ class SegmentIOTrackingTestCase(SegmentIOTrackingTestCaseBase): def test_get_request(self): request = self.request_factory.get(SEGMENTIO_TEST_ENDPOINT) response = segmentio.segmentio_event(request) - self.assertEquals(response.status_code, 405) + self.assertEqual(response.status_code, 405) self.assert_no_events_emitted() @override_settings( @@ -48,19 +48,19 @@ class SegmentIOTrackingTestCase(SegmentIOTrackingTestCaseBase): def test_no_secret_config(self): request = self.request_factory.post(SEGMENTIO_TEST_ENDPOINT) response = segmentio.segmentio_event(request) - self.assertEquals(response.status_code, 401) + self.assertEqual(response.status_code, 401) self.assert_no_events_emitted() def test_no_secret_provided(self): request = self.request_factory.post(SEGMENTIO_TEST_ENDPOINT) response = segmentio.segmentio_event(request) - self.assertEquals(response.status_code, 401) + self.assertEqual(response.status_code, 401) self.assert_no_events_emitted() def test_secret_mismatch(self): request = self.create_request(key='y') response = segmentio.segmentio_event(request) - self.assertEquals(response.status_code, 401) + self.assertEqual(response.status_code, 401) self.assert_no_events_emitted() @data('identify', 'Group', 'Alias', 'Page', 'identify', 'screen') @@ -94,7 +94,7 @@ class SegmentIOTrackingTestCase(SegmentIOTrackingTestCaseBase): self.assert_no_events_emitted() try: response = segmentio.segmentio_event(request) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) expected_event = { 'accept_language': '', @@ -214,7 +214,7 @@ class SegmentIOTrackingTestCase(SegmentIOTrackingTestCaseBase): content_type='application/json' ) response = segmentio.segmentio_event(request) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) self.assert_events_emitted() def test_hiding_failure(self): @@ -225,7 +225,7 @@ class SegmentIOTrackingTestCase(SegmentIOTrackingTestCaseBase): ) response = segmentio.segmentio_event(request) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) self.assert_no_events_emitted() @data( @@ -272,7 +272,7 @@ class SegmentIOTrackingTestCase(SegmentIOTrackingTestCaseBase): middleware.process_request(request) try: response = segmentio.segmentio_event(request) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) expected_event = { 'accept_language': '', @@ -405,7 +405,7 @@ class SegmentIOTrackingTestCase(SegmentIOTrackingTestCaseBase): middleware.process_request(request) try: response = segmentio.segmentio_event(request) - self.assertEquals(response.status_code, 200) + self.assertEqual(response.status_code, 200) expected_event = { 'accept_language': '', diff --git a/common/djangoapps/util/tests/test_db.py b/common/djangoapps/util/tests/test_db.py index 5b080acf98..ae6aed6225 100644 --- a/common/djangoapps/util/tests/test_db.py +++ b/common/djangoapps/util/tests/test_db.py @@ -113,11 +113,11 @@ class TransactionManagersTestCase(TransactionTestCase): with outer_atomic(): atomic()(do_nothing)() - with self.assertRaisesRegexp(TransactionManagementError, 'Cannot be inside an atomic block.'): + with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with atomic(): outer_atomic()(do_nothing)() - with self.assertRaisesRegexp(TransactionManagementError, 'Cannot be inside an atomic block.'): + with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with outer_atomic(): outer_atomic()(do_nothing)() @@ -134,11 +134,11 @@ class TransactionManagersTestCase(TransactionTestCase): commit_on_success(read_committed=True)(do_nothing)() - with self.assertRaisesRegexp(TransactionManagementError, 'Cannot change isolation level when nested.'): + with self.assertRaisesRegex(TransactionManagementError, 'Cannot change isolation level when nested.'): with commit_on_success(): commit_on_success(read_committed=True)(do_nothing)() - with self.assertRaisesRegexp(TransactionManagementError, 'Cannot be inside an atomic block.'): + with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with atomic(): commit_on_success(read_committed=True)(do_nothing)() @@ -162,7 +162,7 @@ class TransactionManagersTestCase(TransactionTestCase): with atomic(): outer_atomic(name='pqr')(do_nothing)() # Not enabled. - with self.assertRaisesRegexp(TransactionManagementError, 'Cannot be inside an atomic block.'): + with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with atomic(): outer_atomic(name='abc')(do_nothing)() @@ -173,19 +173,19 @@ class TransactionManagersTestCase(TransactionTestCase): with atomic(): outer_atomic(name='pqr')(do_nothing)() # Not enabled. - with self.assertRaisesRegexp(TransactionManagementError, 'Cannot be inside an atomic block.'): + with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with atomic(): outer_atomic(name='def')(do_nothing)() - with self.assertRaisesRegexp(TransactionManagementError, 'Cannot be inside an atomic block.'): + with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with outer_atomic(): outer_atomic(name='def')(do_nothing)() - with self.assertRaisesRegexp(TransactionManagementError, 'Cannot be inside an atomic block.'): + with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with atomic(): outer_atomic(name='abc')(do_nothing)() - with self.assertRaisesRegexp(TransactionManagementError, 'Cannot be inside an atomic block.'): + with self.assertRaisesRegex(TransactionManagementError, 'Cannot be inside an atomic block.'): with outer_atomic(): outer_atomic(name='abc')(do_nothing)() diff --git a/common/djangoapps/util/tests/test_keyword_sub_utils.py b/common/djangoapps/util/tests/test_keyword_sub_utils.py index 9648f93415..ec16612899 100644 --- a/common/djangoapps/util/tests/test_keyword_sub_utils.py +++ b/common/djangoapps/util/tests/test_keyword_sub_utils.py @@ -86,7 +86,7 @@ class KeywordSubTest(ModuleStoreTestCase): test_string, self.context, ) - self.assertEquals(test_string, result) + self.assertEqual(test_string, result) def test_should_not_sub(self): """ @@ -97,7 +97,7 @@ class KeywordSubTest(ModuleStoreTestCase): test_string, self.context, ) - self.assertEquals(test_string, result) + self.assertEqual(test_string, result) @file_data('fixtures/test_keywordsub_multiple_tags.json') def test_sub_multiple_tags(self, test_string, expected): diff --git a/common/lib/capa/capa/tests/test_answer_pool.py b/common/lib/capa/capa/tests/test_answer_pool.py index ecd5c7cb41..907fd1648b 100644 --- a/common/lib/capa/capa/tests/test_answer_pool.py +++ b/common/lib/capa/capa/tests/test_answer_pool.py @@ -57,8 +57,8 @@ class CapaAnswerPoolTest(unittest.TestCase): problem = new_loncapa_problem(self.common_question_xml, seed=723) the_html = problem.get_html() # [('choice_3', u'wrong-3'), ('choice_5', u'correct-2'), ('choice_1', u'wrong-2'), ('choice_4', u'wrong-4')] - self.assertRegexpMatches(the_html, r"
.*\[.*'wrong-3'.*'correct-2'.*'wrong-2'.*'wrong-4'.*\].*
") - self.assertRegexpMatches(the_html, r"
\{.*'1_solution_2'.*\}
") + self.assertRegex(the_html, r"
.*\[.*'wrong-3'.*'correct-2'.*'wrong-2'.*'wrong-4'.*\].*
") + self.assertRegex(the_html, r"
\{.*'1_solution_2'.*\}
") self.assertEqual(the_html, problem.get_html(), 'should be able to call get_html() twice') # Check about masking response = list(problem.responders.values())[0] @@ -70,8 +70,8 @@ class CapaAnswerPoolTest(unittest.TestCase): problem = new_loncapa_problem(self.common_question_xml, seed=9) the_html = problem.get_html() # [('choice_0', u'wrong-1'), ('choice_4', u'wrong-4'), ('choice_3', u'wrong-3'), ('choice_2', u'correct-1')] - self.assertRegexpMatches(the_html, r"
.*\[.*'wrong-1'.*'wrong-4'.*'wrong-3'.*'correct-1'.*\].*
") - self.assertRegexpMatches(the_html, r"
\{.*'1_solution_1'.*\}
") + self.assertRegex(the_html, r"
.*\[.*'wrong-1'.*'wrong-4'.*'wrong-3'.*'correct-1'.*\].*
") + self.assertRegex(the_html, r"
\{.*'1_solution_1'.*\}
") # Check about masking response = list(problem.responders.values())[0] self.assertFalse(response.has_mask()) @@ -116,8 +116,8 @@ class CapaAnswerPoolTest(unittest.TestCase): problem = new_loncapa_problem(xml_str) the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'wrong-1'.*'wrong-2'.*'correct-1'.*'wrong-3'.*'wrong-4'.*'correct-2'.*\].*
") - self.assertRegexpMatches(the_html, r"
\{.*'1_solution_1'.*'1_solution_2'.*\}
") + self.assertRegex(the_html, r"
.*\[.*'wrong-1'.*'wrong-2'.*'correct-1'.*'wrong-3'.*'wrong-4'.*'correct-2'.*\].*
") + self.assertRegex(the_html, r"
\{.*'1_solution_1'.*'1_solution_2'.*\}
") self.assertEqual(the_html, problem.get_html(), 'should be able to call get_html() twice') # Check about masking response = list(problem.responders.values())[0] @@ -162,8 +162,8 @@ class CapaAnswerPoolTest(unittest.TestCase): problem = new_loncapa_problem(xml_str) the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'wrong-1'.*'wrong-2'.*'correct-1'.*'wrong-3'.*'wrong-4'.*'correct-2'.*\].*
") - self.assertRegexpMatches(the_html, r"
\{.*'1_solution_1'.*'1_solution_2'.*\}
") + self.assertRegex(the_html, r"
.*\[.*'wrong-1'.*'wrong-2'.*'correct-1'.*'wrong-3'.*'wrong-4'.*'correct-2'.*\].*
") + self.assertRegex(the_html, r"
\{.*'1_solution_1'.*'1_solution_2'.*\}
") response = list(problem.responders.values())[0] self.assertFalse(response.has_mask()) self.assertFalse(response.has_answerpool()) @@ -204,7 +204,7 @@ class CapaAnswerPoolTest(unittest.TestCase): """) - with self.assertRaisesRegexp(LoncapaProblemError, "answer-pool"): + with self.assertRaisesRegex(LoncapaProblemError, "answer-pool"): new_loncapa_problem(xml_str) def test_invalid_answer_pool_none_correct(self): @@ -222,7 +222,7 @@ class CapaAnswerPoolTest(unittest.TestCase): """) - with self.assertRaisesRegexp(LoncapaProblemError, "1 correct.*1 incorrect"): + with self.assertRaisesRegex(LoncapaProblemError, "1 correct.*1 incorrect"): new_loncapa_problem(xml_str) def test_invalid_answer_pool_all_correct(self): @@ -239,7 +239,7 @@ class CapaAnswerPoolTest(unittest.TestCase): """) - with self.assertRaisesRegexp(LoncapaProblemError, "1 correct.*1 incorrect"): + with self.assertRaisesRegex(LoncapaProblemError, "1 correct.*1 incorrect"): new_loncapa_problem(xml_str) def test_answer_pool_5_choices_1_multiplechoiceresponse_seed1(self): @@ -280,8 +280,8 @@ class CapaAnswerPoolTest(unittest.TestCase): problem = new_loncapa_problem(xml_str, seed=723) the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'correct-2'.*'wrong-1'.*'wrong-2'.*.*'wrong-3'.*'wrong-4'.*\].*
") - self.assertRegexpMatches(the_html, r"
\{.*'1_solution_2'.*\}
") + self.assertRegex(the_html, r"
.*\[.*'correct-2'.*'wrong-1'.*'wrong-2'.*.*'wrong-3'.*'wrong-4'.*\].*
") + self.assertRegex(the_html, r"
\{.*'1_solution_2'.*\}
") response = list(problem.responders.values())[0] self.assertFalse(response.has_mask()) self.assertEqual(response.unmask_order(), ['choice_5', 'choice_0', 'choice_1', 'choice_3', 'choice_4']) @@ -360,15 +360,15 @@ class CapaAnswerPoolTest(unittest.TestCase): str3 = r"
\{.*'1_solution_2'.*\}
" str4 = r"
\{.*'1_solution_4'.*\}
" - self.assertRegexpMatches(the_html, str1) - self.assertRegexpMatches(the_html, str2) - self.assertRegexpMatches(the_html, str3) - self.assertRegexpMatches(the_html, str4) + self.assertRegex(the_html, str1) + self.assertRegex(the_html, str2) + self.assertRegex(the_html, str3) + self.assertRegex(the_html, str4) without_new_lines = the_html.replace("\n", "") - self.assertRegexpMatches(without_new_lines, str1 + r".*" + str2) - self.assertRegexpMatches(without_new_lines, str3 + r".*" + str4) + self.assertRegex(without_new_lines, str1 + r".*" + str2) + self.assertRegex(without_new_lines, str3 + r".*" + str4) def test_answer_pool_2_multiplechoiceresponses_seed2(self): xml_str = textwrap.dedent(""" @@ -442,15 +442,15 @@ class CapaAnswerPoolTest(unittest.TestCase): str3 = r"
\{.*'1_solution_1'.*\}
" str4 = r"
\{.*'1_solution_4'.*\}
" - self.assertRegexpMatches(the_html, str1) - self.assertRegexpMatches(the_html, str2) - self.assertRegexpMatches(the_html, str3) - self.assertRegexpMatches(the_html, str4) + self.assertRegex(the_html, str1) + self.assertRegex(the_html, str2) + self.assertRegex(the_html, str3) + self.assertRegex(the_html, str4) without_new_lines = the_html.replace("\n", "") - self.assertRegexpMatches(without_new_lines, str1 + r".*" + str2) - self.assertRegexpMatches(without_new_lines, str3 + r".*" + str4) + self.assertRegex(without_new_lines, str1 + r".*" + str2) + self.assertRegex(without_new_lines, str3 + r".*" + str4) def test_answer_pool_random_consistent(self): """ @@ -516,7 +516,7 @@ class CapaAnswerPoolTest(unittest.TestCase): r"
.*\[.*'correct-1'.*'wrong-4'.*\].*
.*" + r"
.*\[.*'wrong-1'.*'wrong-2'.*'correct-1'.*\].*
") without_new_lines = the_html.replace("\n", "") - self.assertRegexpMatches(without_new_lines, str1) + self.assertRegex(without_new_lines, str1) def test_no_answer_pool(self): xml_str = textwrap.dedent(""" @@ -541,7 +541,7 @@ class CapaAnswerPoolTest(unittest.TestCase): str1 = r"
.*\[.*'wrong-1'.*'wrong-2'.*'correct-1'.*'wrong-3'.*'wrong-4'.*\].*
" - self.assertRegexpMatches(the_html, str1) + self.assertRegex(the_html, str1) # attributes *not* present response = list(problem.responders.values())[0] self.assertFalse(response.has_mask()) @@ -610,15 +610,15 @@ class CapaAnswerPoolTest(unittest.TestCase): str3 = r"
\{.*'1_solution_1'.*\}
" str4 = r"
\{.*'1_solution_3'.*\}
" - self.assertRegexpMatches(the_html, str1) - self.assertRegexpMatches(the_html, str2) - self.assertRegexpMatches(the_html, str3) - self.assertRegexpMatches(the_html, str4) + self.assertRegex(the_html, str1) + self.assertRegex(the_html, str2) + self.assertRegex(the_html, str3) + self.assertRegex(the_html, str4) without_new_lines = the_html.replace("\n", "") - self.assertRegexpMatches(without_new_lines, str1 + r".*" + str2) - self.assertRegexpMatches(without_new_lines, str3 + r".*" + str4) + self.assertRegex(without_new_lines, str1 + r".*" + str2) + self.assertRegex(without_new_lines, str3 + r".*" + str4) def test_answer_pool_without_solutionset(self): xml_str = textwrap.dedent(""" @@ -650,5 +650,5 @@ class CapaAnswerPoolTest(unittest.TestCase): problem = new_loncapa_problem(xml_str, seed=723) the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'wrong-3'.*'correct-2'.*'wrong-2'.*'wrong-4'.*\].*
") - self.assertRegexpMatches(the_html, r"
\{.*'1_solution_1'.*\}
") + self.assertRegex(the_html, r"
.*\[.*'wrong-3'.*'correct-2'.*'wrong-2'.*'wrong-4'.*\].*
") + self.assertRegex(the_html, r"
\{.*'1_solution_1'.*\}
") diff --git a/common/lib/capa/capa/tests/test_capa_problem.py b/common/lib/capa/capa/tests/test_capa_problem.py index 547f2c7570..116960acbc 100644 --- a/common/lib/capa/capa/tests/test_capa_problem.py +++ b/common/lib/capa/capa/tests/test_capa_problem.py @@ -668,7 +668,7 @@ class CAPAProblemReportHelpersTest(unittest.TestCase): """ ) - self.assertEquals(problem.find_answer_text(answer_id, choice_id), answer_text) + self.assertEqual(problem.find_answer_text(answer_id, choice_id), answer_text) @ddt.data( # Test for ChoiceResponse @@ -706,7 +706,7 @@ class CAPAProblemReportHelpersTest(unittest.TestCase): """ ) - self.assertEquals(problem.find_correct_answer_text(answer_id), answer_text) + self.assertEqual(problem.find_correct_answer_text(answer_id), answer_text) def test_find_answer_text_textinput(self): problem = new_loncapa_problem( @@ -718,7 +718,7 @@ class CAPAProblemReportHelpersTest(unittest.TestCase): """ ) - self.assertEquals(problem.find_answer_text('1_2_1', 'hide'), 'hide') + self.assertEqual(problem.find_answer_text('1_2_1', 'hide'), 'hide') def test_get_question_answer(self): problem = new_loncapa_problem( diff --git a/common/lib/capa/capa/tests/test_html_render.py b/common/lib/capa/capa/tests/test_html_render.py index 125709020b..e99e9d1738 100644 --- a/common/lib/capa/capa/tests/test_html_render.py +++ b/common/lib/capa/capa/tests/test_html_render.py @@ -306,7 +306,7 @@ class CapaHtmlRenderTest(unittest.TestCase): # Render the HTML the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
\s*
") + self.assertRegex(the_html, r"
\s*
") def _create_test_file(self, path, content_str): test_fp = self.capa_system.filestore.open(path, "w") diff --git a/common/lib/capa/capa/tests/test_inputtypes.py b/common/lib/capa/capa/tests/test_inputtypes.py index 9b153f7a0f..9e1f6ce213 100644 --- a/common/lib/capa/capa/tests/test_inputtypes.py +++ b/common/lib/capa/capa/tests/test_inputtypes.py @@ -1619,7 +1619,7 @@ class TestChoiceText(unittest.TestCase): Test to ensure having a tag other than inside of a checkbox or radiotextgroup problem raises an error. """ - with self.assertRaisesRegexp(Exception, "Error in xml"): + with self.assertRaisesRegex(Exception, "Error in xml"): self.check_group('checkboxtextgroup', 'invalid', 'checkbox') diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index caeca6f07b..0aa237549b 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -67,9 +67,9 @@ class ResponseTest(unittest.TestCase): input_dict = {'1_2_1': submission} correct_map = problem.grade_answers(input_dict) if msg is None: - self.assertEquals(correct_map.get_correctness('1_2_1'), expected_correctness) + self.assertEqual(correct_map.get_correctness('1_2_1'), expected_correctness) else: - self.assertEquals(correct_map.get_correctness('1_2_1'), expected_correctness, msg) + self.assertEqual(correct_map.get_correctness('1_2_1'), expected_correctness, msg) def assert_answer_format(self, problem): # pylint: disable=missing-docstring answers = problem.get_question_answers() @@ -480,13 +480,13 @@ class FormulaResponseTest(ResponseTest): # Expect to receive a hint if we add an extra y input_dict = {'1_2_1': "x + 2*y + y"} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), + self.assertEqual(correct_map.get_hint('1_2_1'), 'Check the coefficient of y') # Expect to receive a hint if we leave out x input_dict = {'1_2_1': "2*y"} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), + self.assertEqual(correct_map.get_hint('1_2_1'), 'Try including the variable x') def test_script(self): @@ -818,24 +818,24 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring # We should get a hint for Wisconsin input_dict = {'1_2_1': 'Wisconsin'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), + self.assertEqual(correct_map.get_hint('1_2_1'), "The state capital of Wisconsin is Madison") # We should get a hint for Minnesota input_dict = {'1_2_1': 'Minnesota'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), + self.assertEqual(correct_map.get_hint('1_2_1'), "The state capital of Minnesota is St. Paul") # We should NOT get a hint for Michigan (the correct answer) input_dict = {'1_2_1': 'Michigan'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), "") + self.assertEqual(correct_map.get_hint('1_2_1'), "") # We should NOT get a hint for any other string input_dict = {'1_2_1': 'California'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), "") + self.assertEqual(correct_map.get_hint('1_2_1'), "") def test_hints_regexp_and_answer_regexp(self): different_student_answers = [ @@ -867,38 +867,38 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring # We should get a hint for Wisconsin input_dict = {'1_2_1': 'Wisconsin'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), + self.assertEqual(correct_map.get_hint('1_2_1'), "The state capital of Wisconsin is Madison") # We should get a hint for Minnesota input_dict = {'1_2_1': 'Minnesota'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), + self.assertEqual(correct_map.get_hint('1_2_1'), "The state capital of Minnesota is St. Paul") # We should NOT get a hint for Michigan (the correct answer) input_dict = {'1_2_1': 'Michigan'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), "") + self.assertEqual(correct_map.get_hint('1_2_1'), "") # We should NOT get a hint for any other string input_dict = {'1_2_1': 'California'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), "") + self.assertEqual(correct_map.get_hint('1_2_1'), "") # We should get the same hint for each answer for answer in different_student_answers: input_dict = {'1_2_1': answer} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), "First letter of correct answer is M.") + self.assertEqual(correct_map.get_hint('1_2_1'), "First letter of correct answer is M.") input_dict = {'1_2_1': '59'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), "Should not end with 9.") + self.assertEqual(correct_map.get_hint('1_2_1'), "Should not end with 9.") input_dict = {'1_2_1': '57'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), "") + self.assertEqual(correct_map.get_hint('1_2_1'), "") def test_computed_hints(self): problem = self.build_problem( @@ -914,7 +914,7 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring input_dict = {'1_2_1': 'Hello'} correct_map = problem.grade_answers(input_dict) - self.assertEquals(correct_map.get_hint('1_2_1'), "Hello??") + self.assertEqual(correct_map.get_hint('1_2_1'), "Hello??") def test_hint_function_randomization(self): # The hint function should get the seed from the problem. @@ -971,7 +971,7 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring cmap.update(CorrectMap(answer_id=answer_id, queuestate=None)) self.problem.correct_map.update(cmap) - self.assertEquals(self.problem.is_queued(), False) + self.assertEqual(self.problem.is_queued(), False) # Now we queue the LCP cmap = CorrectMap() @@ -980,7 +980,7 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring cmap.update(CorrectMap(answer_id=answer_ids[i], queuestate=queuestate)) self.problem.correct_map.update(cmap) - self.assertEquals(self.problem.is_queued(), True) + self.assertEqual(self.problem.is_queued(), True) def test_update_score(self): ''' @@ -1009,7 +1009,7 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring self.problem.correct_map.update(old_cmap) # Deep copy self.problem.update_score(xserver_msgs[correctness], queuekey=0) - self.assertEquals(self.problem.correct_map.get_dict(), old_cmap.get_dict()) # Deep comparison + self.assertEqual(self.problem.correct_map.get_dict(), old_cmap.get_dict()) # Deep comparison for answer_id in answer_ids: self.assertTrue(self.problem.correct_map.is_queued(answer_id)) # Should be still queued, since message undelivered @@ -1026,7 +1026,7 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring new_cmap.set(answer_id=answer_id, npoints=npoints, correctness=correctness, msg=grader_msg, queuestate=None) self.problem.update_score(xserver_msgs[correctness], queuekey=1000 + i) - self.assertEquals(self.problem.correct_map.get_dict(), new_cmap.get_dict()) + self.assertEqual(self.problem.correct_map.get_dict(), new_cmap.get_dict()) for j, test_id in enumerate(answer_ids): if j == i: @@ -1046,7 +1046,7 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring cmap.update(CorrectMap(answer_id=answer_id, queuestate=None)) self.problem.correct_map.update(cmap) - self.assertEquals(self.problem.get_recentmost_queuetime(), None) + self.assertEqual(self.problem.get_recentmost_queuetime(), None) # CodeResponse requires internal CorrectMap state. Build it now in the queued state cmap = CorrectMap() @@ -1062,7 +1062,7 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring datetime.strftime(latest_timestamp, dateformat), dateformat ).replace(tzinfo=UTC) - self.assertEquals(self.problem.get_recentmost_queuetime(), latest_timestamp) + self.assertEqual(self.problem.get_recentmost_queuetime(), latest_timestamp) def test_convert_files_to_filenames(self): ''' @@ -1074,9 +1074,9 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring '1_3_1': ['answer1', 'answer2', 'answer3'], '1_4_1': [fp, fp]} answers_converted = convert_files_to_filenames(answers_with_file) - self.assertEquals(answers_converted['1_2_1'], 'String-based answer') - self.assertEquals(answers_converted['1_3_1'], ['answer1', 'answer2', 'answer3']) - self.assertEquals(answers_converted['1_4_1'], [fp.name, fp.name]) + self.assertEqual(answers_converted['1_2_1'], 'String-based answer') + self.assertEqual(answers_converted['1_3_1'], ['answer1', 'answer2', 'answer3']) + self.assertEqual(answers_converted['1_4_1'], [fp.name, fp.name]) def test_parse_score_msg_of_responder(self): """ @@ -1116,7 +1116,7 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring self.problem.correct_map = CorrectMap() self.problem.correct_map.update(old_cmap) output = self.problem.update_score(xserver_msgs['correct'], queuekey=1000 + i) - self.assertEquals(output[answer_id]['msg'], grader_msg) + self.assertEqual(output[answer_id]['msg'], grader_msg) for grader_msg in invalid_grader_msgs: correct_score_msg = json.dumps({'correct': True, 'score': 1, 'msg': grader_msg}) @@ -1128,7 +1128,7 @@ class CodeResponseTest(ResponseTest): # pylint: disable=missing-docstring self.problem.correct_map.update(old_cmap) output = self.problem.update_score(xserver_msgs['correct'], queuekey=1000 + i) - self.assertEquals(output[answer_id]['msg'], u'Invalid grader reply. Please contact the course staff.') + self.assertEqual(output[answer_id]['msg'], u'Invalid grader reply. Please contact the course staff.') class ChoiceResponseTest(ResponseTest): # pylint: disable=missing-docstring @@ -1569,7 +1569,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-docstring problem = self.build_problem(answer=staff_ans, tolerance=1e-3) msg = "There was a problem with the staff answer to this problem" - with self.assertRaisesRegexp(StudentInputError, msg): + with self.assertRaisesRegex(StudentInputError, msg): self.assert_grade(problem, '1+j', 'correct') mock_log.debug.assert_called_once_with( @@ -1593,7 +1593,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-docstring problem.capa_system.i18n = FakeTranslations() - with self.assertRaisesRegexp(StudentInputError, "TRANSLATED!"): + with self.assertRaisesRegex(StudentInputError, "TRANSLATED!"): self.assert_grade(problem, '1+j', 'correct') def test_grade_infinity(self): @@ -1646,7 +1646,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-docstring raise err mock_eval.side_effect = evaluator_side_effect - with self.assertRaisesRegexp(StudentInputError, msg_regex): + with self.assertRaisesRegex(StudentInputError, msg_regex): problem.grade_answers({'1_2_1': 'foobar'}) def test_compare_answer(self): @@ -2682,7 +2682,7 @@ class ChoiceTextResponseTest(ResponseTest): "checkboxtextgroup" ) - with self.assertRaisesRegexp(StudentInputError, "Could not interpret"): + with self.assertRaisesRegex(StudentInputError, "Could not interpret"): # Test that error is raised for input in selected correct choice. self.assert_grade( two_choice_two_input, @@ -2690,7 +2690,7 @@ class ChoiceTextResponseTest(ResponseTest): "correct" ) - with self.assertRaisesRegexp(StudentInputError, "Could not interpret"): + with self.assertRaisesRegex(StudentInputError, "Could not interpret"): # Test that error is raised for input in selected incorrect choice. self.assert_grade( two_choice_two_input, @@ -2705,7 +2705,7 @@ class ChoiceTextResponseTest(ResponseTest): ], "checkboxtextgroup" ) - with self.assertRaisesRegexp( + with self.assertRaisesRegex( StudentInputError, "The Staff answer could not be interpreted as a number." ): diff --git a/common/lib/capa/capa/tests/test_shuffle.py b/common/lib/capa/capa/tests/test_shuffle.py index 11f8445b42..6a7cd567de 100644 --- a/common/lib/capa/capa/tests/test_shuffle.py +++ b/common/lib/capa/capa/tests/test_shuffle.py @@ -32,7 +32,7 @@ class CapaShuffleTest(unittest.TestCase): # shuffling 4 things with seed of 0 yields: B A C D # Check that the choices are shuffled the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'Banana'.*'Apple'.*'Chocolate'.*'Donut'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'Banana'.*'Apple'.*'Chocolate'.*'Donut'.*\].*
") # Check that choice name masking is enabled and that unmasking works response = list(problem.responders.values())[0] self.assertFalse(response.has_mask()) @@ -75,7 +75,7 @@ class CapaShuffleTest(unittest.TestCase): """) problem = new_loncapa_problem(xml_str, seed=341) # yields D A B C the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'Donut'.*'Apple'.*'Banana'.*'Chocolate'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'Donut'.*'Apple'.*'Banana'.*'Chocolate'.*\].*
") def test_shuffle_1_choice(self): xml_str = textwrap.dedent(""" @@ -89,7 +89,7 @@ class CapaShuffleTest(unittest.TestCase): """) problem = new_loncapa_problem(xml_str, seed=0) the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'Apple'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'Apple'.*\].*
") response = list(problem.responders.values())[0] self.assertFalse(response.has_mask()) self.assertTrue(response.has_shuffle()) @@ -113,7 +113,7 @@ class CapaShuffleTest(unittest.TestCase): problem = new_loncapa_problem(xml_str, seed=0) # yields: C E A B D F # Donut -> Zonut to show that there is not some hidden alphabetic ordering going on the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'Chocolate'.*'Eggplant'.*'Apple'.*'Banana'.*'Zonut'.*'Filet Mignon'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'Chocolate'.*'Eggplant'.*'Apple'.*'Banana'.*'Zonut'.*'Filet Mignon'.*\].*
") def test_shuffle_false(self): xml_str = textwrap.dedent(""" @@ -130,7 +130,7 @@ class CapaShuffleTest(unittest.TestCase): """) problem = new_loncapa_problem(xml_str) the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'Apple'.*'Banana'.*'Chocolate'.*'Donut'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'Apple'.*'Banana'.*'Chocolate'.*'Donut'.*\].*
") response = list(problem.responders.values())[0] self.assertFalse(response.has_mask()) self.assertFalse(response.has_shuffle()) @@ -153,7 +153,7 @@ class CapaShuffleTest(unittest.TestCase): problem = new_loncapa_problem(xml_str, seed=0) the_html = problem.get_html() # Alpha Beta held back from shuffle (head end) - self.assertRegexpMatches(the_html, r"
.*\[.*'Alpha'.*'Beta'.*'B'.*'A'.*'C'.*'D'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'Alpha'.*'Beta'.*'B'.*'A'.*'C'.*'D'.*\].*
") def test_shuffle_fixed_tail_end(self): xml_str = textwrap.dedent(""" @@ -173,7 +173,7 @@ class CapaShuffleTest(unittest.TestCase): problem = new_loncapa_problem(xml_str, seed=0) the_html = problem.get_html() # Alpha Beta held back from shuffle (tail end) - self.assertRegexpMatches(the_html, r"
.*\[.*'B'.*'A'.*'C'.*'D'.*'Alpha'.*'Beta'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'B'.*'A'.*'C'.*'D'.*'Alpha'.*'Beta'.*\].*
") def test_shuffle_fixed_both_ends(self): xml_str = textwrap.dedent(""" @@ -195,7 +195,7 @@ class CapaShuffleTest(unittest.TestCase): """) problem = new_loncapa_problem(xml_str, seed=0) the_html = problem.get_html() - self.assertRegexpMatches( + self.assertRegex( the_html, r"
.*\[.*'Alpha'.*'Beta'.*'B'.*'A'.*'C'.*'D'.*'Psi'.*'Omega'.*\].*
" ) @@ -214,7 +214,7 @@ class CapaShuffleTest(unittest.TestCase): """) problem = new_loncapa_problem(xml_str, seed=0) the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'Alpha'.*'A'.*'Omega'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'Alpha'.*'A'.*'Omega'.*\].*
") def test_shuffle_fixed_all(self): xml_str = textwrap.dedent(""" @@ -230,7 +230,7 @@ class CapaShuffleTest(unittest.TestCase): """) problem = new_loncapa_problem(xml_str, seed=0) the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'A'.*'B'.*'C'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'A'.*'B'.*'C'.*\].*
") def test_shuffle_island(self): """A fixed 'island' choice not at the head or tail end gets lumped into the tail end.""" @@ -249,7 +249,7 @@ class CapaShuffleTest(unittest.TestCase): """) problem = new_loncapa_problem(xml_str, seed=0) the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"
.*\[.*'A'.*'Mid'.*'Mid'.*'C'.*'D'.*\].*
") + self.assertRegex(the_html, r"
.*\[.*'A'.*'Mid'.*'Mid'.*'C'.*'D'.*\].*
") def test_multiple_shuffle_responses(self): xml_str = textwrap.dedent(""" @@ -278,7 +278,7 @@ class CapaShuffleTest(unittest.TestCase): self.assertEqual(orig_html, problem.get_html(), 'should be able to call get_html() twice') html = orig_html.replace('\n', ' ') # avoid headaches with .* matching print(html) - self.assertRegexpMatches(html, r"
.*\[.*'Banana'.*'Apple'.*'Chocolate'.*'Donut'.*\].*
.*" + + self.assertRegex(html, r"
.*\[.*'Banana'.*'Apple'.*'Chocolate'.*'Donut'.*\].*
.*" + r"
.*\[.*'C'.*'A'.*'D'.*'B'.*\].*
") # Look at the responses in their authored order responses = sorted(list(problem.responders.values()), key=lambda resp: int(resp.id[resp.id.rindex('_') + 1:])) @@ -304,5 +304,5 @@ class CapaShuffleTest(unittest.TestCase): """) - with self.assertRaisesRegexp(LoncapaProblemError, "shuffle and answer-pool"): + with self.assertRaisesRegex(LoncapaProblemError, "shuffle and answer-pool"): new_loncapa_problem(xml_str) diff --git a/common/lib/capa/capa/tests/test_targeted_feedback.py b/common/lib/capa/capa/tests/test_targeted_feedback.py index d3268ee2b2..5dfbf54070 100644 --- a/common/lib/capa/capa/tests/test_targeted_feedback.py +++ b/common/lib/capa/capa/tests/test_targeted_feedback.py @@ -82,17 +82,17 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") - self.assertRegexpMatches(without_new_lines, r"
.*'wrong-1'.*'wrong-2'.*'correct-1'.*'wrong-3'.*
") - self.assertRegexpMatches(without_new_lines, r"feedback1|feedback2|feedback3|feedbackC") + self.assertRegex(without_new_lines, r"
.*'wrong-1'.*'wrong-2'.*'correct-1'.*'wrong-3'.*
") + self.assertRegex(without_new_lines, r"feedback1|feedback2|feedback3|feedbackC") def test_targeted_feedback_not_finished(self): problem = new_loncapa_problem(load_fixture('targeted_feedback.xml')) the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") - self.assertRegexpMatches(without_new_lines, r"
.*'wrong-1'.*'wrong-2'.*'correct-1'.*'wrong-3'.*
") + self.assertRegex(without_new_lines, r"
.*'wrong-1'.*'wrong-2'.*'correct-1'.*'wrong-3'.*
") self.assertNotRegexpMatches(without_new_lines, r"feedback1|feedback2|feedback3|feedbackC") - self.assertEquals(the_html, problem.get_html(), "Should be able to call get_html() twice") + self.assertEqual(the_html, problem.get_html(), "Should be able to call get_html() twice") def test_targeted_feedback_student_answer1(self): problem = new_loncapa_problem(load_fixture('targeted_feedback.xml')) @@ -102,11 +102,11 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\\n", "").replace("\n", "") # pylint: disable=line-too-long - self.assertRegexpMatches(without_new_lines, r"\s*Incorrect.*3rd WRONG solution") + self.assertRegex(without_new_lines, r"\s*Incorrect.*3rd WRONG solution") self.assertNotRegexpMatches(without_new_lines, r"feedback1|feedback2|feedbackC") # Check that calling it multiple times yields the same thing the_html2 = problem.get_html() - self.assertEquals(the_html, the_html2) + self.assertEqual(the_html, the_html2) def test_targeted_feedback_student_answer2(self): problem = new_loncapa_problem(load_fixture('targeted_feedback.xml')) @@ -116,8 +116,8 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\\n", "").replace("\n", "") # pylint: disable=line-too-long - self.assertRegexpMatches(without_new_lines, r"\s*Incorrect.*1st WRONG solution") - self.assertRegexpMatches(without_new_lines, r"
\{.*'1_solution_1'.*\}
") + self.assertRegex(without_new_lines, r"\s*Incorrect.*1st WRONG solution") + self.assertRegex(without_new_lines, r"
\{.*'1_solution_1'.*\}
") self.assertNotRegexpMatches(without_new_lines, r"feedback2|feedback3|feedbackC") def test_targeted_feedback_correct_answer(self): @@ -129,7 +129,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\\n", "").replace("\n", "") # pylint: disable=line-too-long - self.assertRegexpMatches(without_new_lines, + self.assertRegex(without_new_lines, r"\s*Correct.*Feedback on your correct solution...") self.assertNotRegexpMatches(without_new_lines, r"feedback1|feedback2|feedback3") @@ -193,14 +193,14 @@ class CapaTargetedFeedbackTest(unittest.TestCase): problem.done = True problem.student_answers = {'1_2_1': 'choice_0'} the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"\s*") + self.assertRegex(the_html, r"\s*") # New problem with same XML -- try the correct choice. problem = new_loncapa_problem(xml_str) problem.done = True problem.student_answers = {'1_2_1': 'choice_2'} # correct the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"\s*") + self.assertRegex(the_html, r"\s*") def test_targeted_feedback_no_solution_element(self): xml_str = textwrap.dedent(""" @@ -232,7 +232,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") #
right after - self.assertRegexpMatches( + self.assertRegex( without_new_lines, r"
.*.*\s*
" ) @@ -299,13 +299,13 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") # pylint: disable=line-too-long - self.assertRegexpMatches(without_new_lines, r".*1st WRONG solution") - self.assertRegexpMatches(without_new_lines, r".*1st WRONG solution") + self.assertRegex(without_new_lines, r"\{.*'1_solution_1'.*\}") self.assertNotRegexpMatches(without_new_lines, r"feedback2|feedback3") # Check that calling it multiple times yields the same thing the_html2 = problem.get_html() - self.assertEquals(the_html, the_html2) + self.assertEqual(the_html, the_html2) def test_targeted_feedback_no_show_solution_explanation(self): xml_str = textwrap.dedent(""" @@ -369,9 +369,9 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") # pylint: disable=line-too-long - self.assertRegexpMatches(without_new_lines, r".*1st WRONG solution") + self.assertRegex(without_new_lines, r".*1st WRONG solution") self.assertNotRegexpMatches(without_new_lines, r"\{.*'1_solution_1'.*\}") + self.assertRegex(without_new_lines, r"
\{.*'1_solution_1'.*\}
") self.assertNotRegexpMatches(without_new_lines, r"feedback2|feedback3|feedbackC") def test_targeted_feedback_with_solutionset_explanation(self): @@ -446,8 +446,8 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") # pylint: disable=line-too-long - self.assertRegexpMatches(without_new_lines, r".*1st WRONG solution") - self.assertRegexpMatches(without_new_lines, r".*1st WRONG solution") + self.assertRegex(without_new_lines, r"\{.*'1_solution_1'.*\}") self.assertNotRegexpMatches(without_new_lines, r"feedback2|feedback3") @@ -510,7 +510,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") - self.assertRegexpMatches(without_new_lines, r"\{.*'1_solution_1'.*\}") self.assertNotRegexpMatches(without_new_lines, r"feedback1|feedback3") @@ -573,7 +573,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): without_new_lines = the_html.replace("\n", "") self.assertNotRegexpMatches(without_new_lines, r"\{.*'1_solution_1'.*\}") + self.assertRegex(without_new_lines, r"
\{.*'1_solution_1'.*\}
") self.assertNotRegexpMatches(without_new_lines, r"feedback1|feedback3|feedbackC") def test_targeted_feedback_multiple_not_answered(self): @@ -582,7 +582,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") # Q1 and Q2 have no feedback - self.assertRegexpMatches( + self.assertRegex( without_new_lines, r'\s*.*\s*' ) @@ -594,7 +594,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") # Q1 has feedback1 and Q2 has nothing - self.assertRegexpMatches( + self.assertRegex( without_new_lines, r'.*?explanation-id="feedback1".*?.*' + r'\s*' @@ -607,7 +607,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") # Q1 has feedback1 and Q2 has feedbackC - self.assertRegexpMatches( + self.assertRegex( without_new_lines, r'.*?explanation-id="feedback1".*?.*' + r'.*explanation-id="feedbackC".*?' diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py index 8eeb678262..0bdc6bbcc2 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -284,7 +284,7 @@ class CommonMixedModuleStoreSetup(CourseComparisonTest): ).make_usage_key('vertical', 'fake') self._create_course(test_course_key) - self.assertEquals(default, self.store.get_modulestore_type(self.course.id)) + self.assertEqual(default, self.store.get_modulestore_type(self.course.id)) class AsideFoo(XBlockAside): @@ -462,9 +462,9 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup): blocks = self.store.get_items(self.course.id, qualifiers={'category': 'problem'}) blocks.append(self.store.get_item(self.problem_x1a_1)) - self.assertEquals(len(blocks), 7) + self.assertEqual(len(blocks), 7) for block in blocks: - self.assertEquals(block.course_version, course_version) + self.assertEqual(block.course_version, course_version) # ensure that when the block is retrieved from the runtime cache, # the course version is still present cached_block = course.runtime.load_item(block.location) @@ -1069,7 +1069,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup): draft_courses = self.store.get_courses(remove_branch=True) with self.store.branch_setting(ModuleStoreEnum.Branch.published_only): published_courses = self.store.get_courses(remove_branch=True) - self.assertEquals([c.id for c in draft_courses], [c.id for c in published_courses]) + self.assertEqual([c.id for c in draft_courses], [c.id for c in published_courses]) @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) def test_create_child_detached_tabs(self, default_ms): @@ -2326,7 +2326,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup): """ Asserts the number of problems with the given display name is the given expected number. """ - self.assertEquals( + self.assertEqual( len(self.store.get_items(course_key.for_branch(None), settings={'display_name': display_name})), expected_number ) @@ -2337,7 +2337,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup): """ # check the display_name of the problem problem = self.store.get_item(problem_location) - self.assertEquals(problem.display_name, expected_display_name) + self.assertEqual(problem.display_name, expected_display_name) # there should be only 1 problem with the expected_display_name assertNumProblems(expected_display_name, 1) @@ -2392,25 +2392,25 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup): # verify branch setting is published-only in manager with self.store.branch_setting(ModuleStoreEnum.Branch.published_only): - self.assertEquals(self.store.get_branch_setting(), ModuleStoreEnum.Branch.published_only) + self.assertEqual(self.store.get_branch_setting(), ModuleStoreEnum.Branch.published_only) # verify branch setting is draft-preferred in manager with self.store.branch_setting(ModuleStoreEnum.Branch.draft_preferred): - self.assertEquals(self.store.get_branch_setting(), ModuleStoreEnum.Branch.draft_preferred) + self.assertEqual(self.store.get_branch_setting(), ModuleStoreEnum.Branch.draft_preferred) def verify_default_store(self, store_type): """ Verifies the default_store property """ - self.assertEquals(self.store.default_modulestore.get_modulestore_type(), store_type) + self.assertEqual(self.store.default_modulestore.get_modulestore_type(), store_type) # verify internal helper method store = self.store._get_modulestore_for_courselike() # pylint: disable=protected-access - self.assertEquals(store.get_modulestore_type(), store_type) + self.assertEqual(store.get_modulestore_type(), store_type) # verify store used for creating a course course = self.store.create_course("org", "course{}".format(uuid4().hex[:5]), "run", self.user_id) - self.assertEquals(course.system.modulestore.get_modulestore_type(), store_type) + self.assertEqual(course.system.modulestore.get_modulestore_type(), store_type) @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) def test_default_store(self, default_ms): @@ -2444,7 +2444,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup): self._initialize_mixed(mappings={}) fake_store = "fake" - with self.assertRaisesRegexp(Exception, "Cannot find store of type {}".format(fake_store)): + with self.assertRaisesRegex(Exception, "Cannot find store of type {}".format(fake_store)): with self.store.default_store(fake_store): pass # pragma: no cover @@ -3420,7 +3420,7 @@ class TestPublishOverExportImport(CommonMixedModuleStoreSetup): raise_on_failure=True, ) - self.assertEquals(1, len(courses2)) + self.assertEqual(1, len(courses2)) # check that the imported blocks have the right asides and values def check_block(block): @@ -3518,11 +3518,11 @@ class TestPublishOverExportImport(CommonMixedModuleStoreSetup): raise_on_failure=True, ) - self.assertEquals(1, len(courses2)) + self.assertEqual(1, len(courses2)) # check that aside for the new chapter was exported/imported properly chapters = courses2[0].get_children() - self.assertEquals(2, len(chapters)) + self.assertEqual(2, len(chapters)) self.assertIn(new_chapter_display_name, [item.display_name for item in chapters]) found = False @@ -3533,14 +3533,14 @@ class TestPublishOverExportImport(CommonMixedModuleStoreSetup): self.assertEqual(len(asides), 1) child_aside = asides[0] self.assertIsInstance(child_aside, AsideTestType) - self.assertEquals(child_aside.data_field, 'new value') + self.assertEqual(child_aside.data_field, 'new value') break self.assertTrue(found, "new_chapter not found") # check that aside for the new problem was exported/imported properly sequence_children = courses2[0].get_children()[0].get_children()[0].get_children() - self.assertEquals(2, len(sequence_children)) + self.assertEqual(2, len(sequence_children)) self.assertIn(new_problem_display_name, [item.display_name for item in sequence_children]) found = False @@ -3551,8 +3551,8 @@ class TestPublishOverExportImport(CommonMixedModuleStoreSetup): self.assertEqual(len(asides), 1) child_aside = asides[0] self.assertIsInstance(child_aside, AsideTestType) - self.assertEquals(child_aside.data_field, 'new problem value') - self.assertEquals(child_aside.content, 'new content value') + self.assertEqual(child_aside.data_field, 'new problem value') + self.assertEqual(child_aside.content, 'new content value') break self.assertTrue(found, "new_chapter not found") @@ -3716,8 +3716,8 @@ class TestAsidesWithMixedModuleStore(CommonMixedModuleStoreSetup): ) asides = published_xblock.runtime.get_asides(published_xblock) - self.assertEquals(asides[0].field11, 'new_value11') - self.assertEquals(asides[0].field12, 'new_value12') + self.assertEqual(asides[0].field11, 'new_value11') + self.assertEqual(asides[0].field12, 'new_value12') # remove item self.store.delete_item(published_xblock.location, self.user_id) @@ -3732,8 +3732,8 @@ class TestAsidesWithMixedModuleStore(CommonMixedModuleStoreSetup): # check that aside has default values asides2 = published_xblock2.runtime.get_asides(published_xblock2) - self.assertEquals(asides2[0].field11, 'aside1_default_value1') - self.assertEquals(asides2[0].field12, 'aside1_default_value2') + self.assertEqual(asides2[0].field11, 'aside1_default_value1') + self.assertEqual(asides2[0].field12, 'aside1_default_value2') @ddt.data((ModuleStoreEnum.Type.mongo, 1, 0), (ModuleStoreEnum.Type.split, 2, 0)) @XBlockAside.register_temp_plugin(AsideFoo, 'test_aside1') @@ -3760,8 +3760,8 @@ class TestAsidesWithMixedModuleStore(CommonMixedModuleStoreSetup): def _check_asides(item): """ Helper function to check asides """ asides = item.runtime.get_asides(item) - self.assertEquals(asides[0].field11, 'new_value11') - self.assertEquals(asides[0].field12, 'new_value12') + self.assertEqual(asides[0].field11, 'new_value11') + self.assertEqual(asides[0].field12, 'new_value12') # start off as Private item = self.store.create_child(self.user_id, self.writable_chapter_location, 'problem', diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py b/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py index 2484a6b5b3..a5f685d4a8 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py @@ -151,9 +151,9 @@ class ModuleStoreSettingsMigration(TestCase): split_settings = [store for store in stores if store['ENGINE'].endswith('.DraftVersioningModuleStore')] if len(split_settings): # there should only be one setting for split - self.assertEquals(len(split_settings), 1) + self.assertEqual(len(split_settings), 1) # verify name - self.assertEquals(split_settings[0]['NAME'], 'split') + self.assertEqual(split_settings[0]['NAME'], 'split') # verify split config settings equal those of mongo self.assertStoreValuesEqual( split_settings[0], @@ -195,7 +195,7 @@ class ModuleStoreSettingsMigration(TestCase): old_mixed_setting = self.ALREADY_UPDATED_MIXED_CONFIG new_mixed_setting, new_default_store_setting = self.assertMigrated(old_mixed_setting) self.assertTrue(self.is_split_configured(new_mixed_setting)) - self.assertEquals(old_mixed_setting, new_mixed_setting) + self.assertEqual(old_mixed_setting, new_mixed_setting) @ddt.data('draft', 'split') def test_update_settings(self, default_store): diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py index 599a810024..ff6e7866ea 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py @@ -744,7 +744,7 @@ class TestMongoModuleStoreWithNoAssetCollection(TestMongoModuleStore): courses = self.draft_store.get_courses() course = courses[0] # Confirm that no specified asset collection name means empty asset metadata. - self.assertEquals(self.draft_store.get_all_asset_metadata(course.id, 'asset'), []) + self.assertEqual(self.draft_store.get_all_asset_metadata(course.id, 'asset'), []) def test_no_asset_invalid_key(self): course_key = CourseLocator(org="edx3", course="test_course", run=None, deprecated=True) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_publish.py b/common/lib/xmodule/xmodule/modulestore/tests/test_publish.py index 4d970144e9..62d792859d 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_publish.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_publish.py @@ -364,7 +364,7 @@ class OLXFormatChecker(unittest.TestCase): to match against the named attribute. """ for attribute, regex in attrs.items(): - self.assertRegexpMatches(element.get(attribute), regex) + self.assertRegex(element.get(attribute), regex) def parse_olx(self, block_type, block_id, **kwargs): """ diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py index c12915a620..ac200b8f8c 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py @@ -1819,7 +1819,7 @@ class TestCourseCreation(SplitModuleTest): 'best', 'leech', 'leech_run', 'leech_master', BRANCH_NAME_DRAFT, versions_dict=original_index['versions']) new_draft_locator = new_draft.location - self.assertRegexpMatches(new_draft_locator.org, 'best') + self.assertRegex(new_draft_locator.org, 'best') # the edited_by and other meta fields on the new course will be the original author not this one self.assertEqual(new_draft.edited_by, 'test@edx.org') self.assertEqual(new_draft_locator.version_guid, original_index['versions'][BRANCH_NAME_DRAFT]) @@ -1869,7 +1869,7 @@ class TestCourseCreation(SplitModuleTest): fields=fields ) new_draft_locator = new_draft.location - self.assertRegexpMatches(new_draft_locator.org, 'counter') + self.assertRegex(new_draft_locator.org, 'counter') # the edited_by and other meta fields on the new course will be the original author not this one self.assertEqual(new_draft.edited_by, 'leech_master') self.assertNotEqual(new_draft_locator.version_guid, original_index['versions'][BRANCH_NAME_DRAFT]) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore_bulk_operations.py b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore_bulk_operations.py index 872033d390..fed42c71c5 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore_bulk_operations.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore_bulk_operations.py @@ -291,7 +291,7 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin): ) def test_version_structure_creates_new_version(self): - self.assertNotEquals( + self.assertNotEqual( self.bulk.version_structure(self.course_key, self.structure, 'user_id')['_id'], self.structure['_id'] ) @@ -301,7 +301,7 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin): self.bulk._begin_bulk_operation(self.course_key) version_result = self.bulk.version_structure(self.course_key, self.structure, 'user_id') get_result = self.bulk.get_structure(self.course_key, version_result['_id']) - self.assertEquals(version_result, get_result) + self.assertEqual(version_result, get_result) class TestBulkWriteMixinClosedAfterPrevTransaction(TestBulkWriteMixinClosed, TestBulkWriteMixinPreviousTransaction): @@ -463,7 +463,7 @@ class TestBulkWriteMixinFindMethods(TestBulkWriteMixin): self.conn.get_definitions.assert_called_once_with(definitions_gotten, self.course_key) else: # If no definitions to get, then get_definitions() should *not* have been called. - self.assertEquals(self.conn.get_definitions.call_count, 0) + self.assertEqual(self.conn.get_definitions.call_count, 0) for _id in active_ids: if _id in search_ids: self.assertIn(active_definition(_id), results) @@ -604,7 +604,7 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): # returns the structure from the database version_guid = VERSION_GUID_DICT[version_guid_name] result = self.bulk.get_structure(self.course_key, version_guid) - self.assertEquals(self.conn.get_structure.call_count, 1) + self.assertEqual(self.conn.get_structure.call_count, 1) self.assertEqual(result, self.conn.get_structure.return_value) self.assertCacheNotCleared() @@ -615,7 +615,7 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): version_guid = VERSION_GUID_DICT[version_guid_name] for _ in range(2): result = self.bulk.get_structure(self.course_key, version_guid) - self.assertEquals(self.conn.get_structure.call_count, 1) + self.assertEqual(self.conn.get_structure.call_count, 1) self.assertEqual(result, self.conn.get_structure.return_value) self.assertCacheNotCleared() @@ -626,7 +626,7 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): self.structure['_id'] = version_guid self.bulk.update_structure(self.course_key, self.structure) result = self.bulk.get_structure(self.course_key, version_guid) - self.assertEquals(self.conn.get_structure.call_count, 0) + self.assertEqual(self.conn.get_structure.call_count, 0) self.assertEqual(result, self.structure) @ddt.data(*SAMPLE_GUIDS_LIST) @@ -638,7 +638,7 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): self.bulk.get_structure(self.course_key, version_guid) self.bulk.update_structure(self.course_key, self.structure) result = self.bulk.get_structure(self.course_key, version_guid) - self.assertEquals(self.conn.get_structure.call_count, 1) + self.assertEqual(self.conn.get_structure.call_count, 1) self.assertEqual(result, self.structure) @ddt.data(*SAMPLE_GUIDS_LIST) @@ -647,7 +647,7 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): # returns the definition from the database version_guid = VERSION_GUID_DICT[version_guid_name] result = self.bulk.get_definition(self.course_key, version_guid) - self.assertEquals(self.conn.get_definition.call_count, 1) + self.assertEqual(self.conn.get_definition.call_count, 1) self.assertEqual(result, self.conn.get_definition.return_value) self.assertCacheNotCleared() @@ -658,7 +658,7 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): version_guid = VERSION_GUID_DICT[version_guid_name] for _ in range(2): result = self.bulk.get_definition(self.course_key, version_guid) - self.assertEquals(self.conn.get_definition.call_count, 1) + self.assertEqual(self.conn.get_definition.call_count, 1) self.assertEqual(result, self.conn.get_definition.return_value) self.assertCacheNotCleared() @@ -669,7 +669,7 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): self.definition['_id'] = version_guid self.bulk.update_definition(self.course_key, self.definition) result = self.bulk.get_definition(self.course_key, version_guid) - self.assertEquals(self.conn.get_definition.call_count, 0) + self.assertEqual(self.conn.get_definition.call_count, 0) self.assertEqual(result, self.definition) @ddt.data(*SAMPLE_GUIDS_LIST) @@ -681,15 +681,15 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): self.bulk.get_definition(self.course_key, version_guid) self.bulk.update_definition(self.course_key, self.definition) result = self.bulk.get_definition(self.course_key, version_guid) - self.assertEquals(self.conn.get_definition.call_count, 1) + self.assertEqual(self.conn.get_definition.call_count, 1) self.assertEqual(result, self.definition) @ddt.data(True, False) def test_read_index_without_write_from_db(self, ignore_case): # Reading the index without writing to it should pull from the database result = self.bulk.get_course_index(self.course_key, ignore_case=ignore_case) - self.assertEquals(self.conn.get_course_index.call_count, 1) - self.assertEquals(self.conn.get_course_index.return_value, result) + self.assertEqual(self.conn.get_course_index.call_count, 1) + self.assertEqual(self.conn.get_course_index.return_value, result) @ddt.data(True, False) def test_read_index_without_write_only_reads_once(self, ignore_case): @@ -697,8 +697,8 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): # the database for _ in range(2): result = self.bulk.get_course_index(self.course_key, ignore_case=ignore_case) - self.assertEquals(self.conn.get_course_index.call_count, 1) - self.assertEquals(self.conn.get_course_index.return_value, result) + self.assertEqual(self.conn.get_course_index.call_count, 1) + self.assertEqual(self.conn.get_course_index.return_value, result) @ddt.data(True, False) def test_read_index_after_write(self, ignore_case): @@ -706,8 +706,8 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): # initial index, and should return the written index_entry self.bulk.insert_course_index(self.course_key, self.index_entry) result = self.bulk.get_course_index(self.course_key, ignore_case=ignore_case) - self.assertEquals(self.conn.get_course_index.call_count, 1) - self.assertEquals(self.index_entry, result) + self.assertEqual(self.conn.get_course_index.call_count, 1) + self.assertEqual(self.index_entry, result) def test_read_index_ignore_case(self): # Reading using ignore case should find an already written entry with a different case @@ -720,11 +720,11 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): ), ignore_case=True ) - self.assertEquals(self.conn.get_course_index.call_count, 1) - self.assertEquals(self.index_entry, result) + self.assertEqual(self.conn.get_course_index.call_count, 1) + self.assertEqual(self.index_entry, result) def test_version_structure_creates_new_version_before_read(self): - self.assertNotEquals( + self.assertNotEqual( self.bulk.version_structure(self.course_key, self.structure, 'user_id')['_id'], self.structure['_id'] ) @@ -732,7 +732,7 @@ class TestBulkWriteMixinOpen(TestBulkWriteMixin): def test_version_structure_creates_new_version_after_read(self): self.conn.get_structure.return_value = copy.deepcopy(self.structure) self.bulk.get_structure(self.course_key, self.structure['_id']) - self.assertNotEquals( + self.assertNotEqual( self.bulk.version_structure(self.course_key, self.structure, 'user_id')['_id'], self.structure['_id'] ) diff --git a/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py b/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py index 5418c7dd4d..276574f6c6 100644 --- a/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py +++ b/common/lib/xmodule/xmodule/partitions/tests/test_partitions.py @@ -74,7 +74,7 @@ class TestGroup(TestCase): "name": name, "version": -1, } - with self.assertRaisesRegexp(TypeError, "has unexpected version"): + with self.assertRaisesRegex(TypeError, "has unexpected version"): Group.from_json(jsonified) # Missing key "id" @@ -82,7 +82,7 @@ class TestGroup(TestCase): "name": name, "version": Group.VERSION } - with self.assertRaisesRegexp(TypeError, "missing value key 'id'"): + with self.assertRaisesRegex(TypeError, "missing value key 'id'"): Group.from_json(jsonified) # Has extra key - should not be a problem @@ -197,8 +197,8 @@ class TestUserPartition(PartitionTestCase): self.assertEqual(user_partition.name, self.TEST_NAME) self.assertEqual(user_partition.description, self.TEST_DESCRIPTION) self.assertEqual(user_partition.groups, self.TEST_GROUPS) - self.assertEquals(user_partition.scheme.name, self.TEST_SCHEME_NAME) - self.assertEquals(user_partition.parameters, self.TEST_PARAMETERS) + self.assertEqual(user_partition.scheme.name, self.TEST_SCHEME_NAME) + self.assertEqual(user_partition.parameters, self.TEST_PARAMETERS) def test_string_id(self): user_partition = UserPartition( @@ -273,7 +273,7 @@ class TestUserPartition(PartitionTestCase): "groups": [group.to_json() for group in self.TEST_GROUPS], "version": 2, } - with self.assertRaisesRegexp(TypeError, "missing value key 'scheme'"): + with self.assertRaisesRegex(TypeError, "missing value key 'scheme'"): UserPartition.from_json(jsonified) # Test that version 3 partitions have a scheme specified @@ -317,7 +317,7 @@ class TestUserPartition(PartitionTestCase): "version": UserPartition.VERSION, "scheme": self.TEST_SCHEME_NAME, } - with self.assertRaisesRegexp(TypeError, "missing value key 'id'"): + with self.assertRaisesRegex(TypeError, "missing value key 'id'"): UserPartition.from_json(jsonified) # Missing scheme @@ -329,7 +329,7 @@ class TestUserPartition(PartitionTestCase): "groups": [group.to_json() for group in self.TEST_GROUPS], "version": UserPartition.VERSION, } - with self.assertRaisesRegexp(TypeError, "missing value key 'scheme'"): + with self.assertRaisesRegex(TypeError, "missing value key 'scheme'"): UserPartition.from_json(jsonified) # Invalid scheme @@ -342,7 +342,7 @@ class TestUserPartition(PartitionTestCase): "version": UserPartition.VERSION, "scheme": "no_such_scheme", } - with self.assertRaisesRegexp(UserPartitionError, "Unrecognized scheme"): + with self.assertRaisesRegex(UserPartitionError, "Unrecognized scheme"): UserPartition.from_json(jsonified) # Wrong version @@ -355,7 +355,7 @@ class TestUserPartition(PartitionTestCase): "version": -1, "scheme": self.TEST_SCHEME_NAME, } - with self.assertRaisesRegexp(TypeError, "has unexpected version"): + with self.assertRaisesRegex(TypeError, "has unexpected version"): UserPartition.from_json(jsonified) # Has extra key - should not be a problem diff --git a/common/lib/xmodule/xmodule/tests/__init__.py b/common/lib/xmodule/xmodule/tests/__init__.py index 739a0d883d..5799b6a51f 100644 --- a/common/lib/xmodule/xmodule/tests/__init__.py +++ b/common/lib/xmodule/xmodule/tests/__init__.py @@ -501,10 +501,10 @@ class CourseComparisonTest(TestCase): actual_course_assets = actual_modulestore.get_all_asset_metadata( actual_course_key, None, sort=('displayname', ModuleStoreEnum.SortOrder.descending) ) - self.assertEquals(len(expected_course_assets), len(actual_course_assets)) + self.assertEqual(len(expected_course_assets), len(actual_course_assets)) for idx, __ in enumerate(expected_course_assets): for attr in AssetMetadata.ATTRS_ALLOWED_TO_UPDATE: if attr in ('edited_on',): # edited_on is updated upon import. continue - self.assertEquals(getattr(expected_course_assets[idx], attr), getattr(actual_course_assets[idx], attr)) + self.assertEqual(getattr(expected_course_assets[idx], attr), getattr(actual_course_assets[idx], attr)) diff --git a/common/lib/xmodule/xmodule/tests/test_conditional.py b/common/lib/xmodule/xmodule/tests/test_conditional.py index 84c4864487..7e4b459571 100644 --- a/common/lib/xmodule/xmodule/tests/test_conditional.py +++ b/common/lib/xmodule/xmodule/tests/test_conditional.py @@ -173,7 +173,7 @@ class ConditionalModuleBasicTest(unittest.TestCase): 'element_id': u'i4x-edX-conditional_test-conditional-SampleConditional', 'depends': u'i4x-edX-conditional_test-problem-SampleProblem', }) - self.assertEquals(expected, html) + self.assertEqual(expected, html) def test_handle_ajax(self): modules = ConditionalFactory.create(self.test_system) @@ -238,7 +238,7 @@ class ConditionalModuleXmlTest(unittest.TestCase): modulestore = XMLModuleStore(DATA_DIR, source_dirs=[name]) courses = modulestore.get_courses() self.modulestore = modulestore - self.assertEquals(len(courses), 1) + self.assertEqual(len(courses), 1) return courses[0] def test_conditional_module(self): diff --git a/common/lib/xmodule/xmodule/tests/test_delay_between_attempts.py b/common/lib/xmodule/xmodule/tests/test_delay_between_attempts.py index 83dc482e3d..5cdfa56e1d 100644 --- a/common/lib/xmodule/xmodule/tests/test_delay_between_attempts.py +++ b/common/lib/xmodule/xmodule/tests/test_delay_between_attempts.py @@ -182,7 +182,7 @@ class XModuleQuizAttemptsDelayTest(unittest.TestCase): ) # You should get a dialog that tells you to wait # Also, the number of attempts should not be incremented - self.assertRegexpMatches(result['success'], r"You must wait at least.*") + self.assertRegex(result['success'], r"You must wait at least.*") self.assertEqual(module.attempts, num_attempts) def test_submit_quiz_too_soon(self): @@ -196,7 +196,7 @@ class XModuleQuizAttemptsDelayTest(unittest.TestCase): ) # You should get a dialog that tells you to wait 2 minutes # Also, the number of attempts should not be incremented - self.assertRegexpMatches(result['success'], r"You must wait at least 3 minutes between submissions. 2 minutes remaining\..*") + self.assertRegex(result['success'], r"You must wait at least 3 minutes between submissions. 2 minutes remaining\..*") self.assertEqual(module.attempts, num_attempts) def test_submit_quiz_1_second_too_soon(self): @@ -210,7 +210,7 @@ class XModuleQuizAttemptsDelayTest(unittest.TestCase): ) # You should get a dialog that tells you to wait 2 minutes # Also, the number of attempts should not be incremented - self.assertRegexpMatches(result['success'], r"You must wait at least 3 minutes between submissions. 1 second remaining\..*") + self.assertRegex(result['success'], r"You must wait at least 3 minutes between submissions. 1 second remaining\..*") self.assertEqual(module.attempts, num_attempts) def test_submit_quiz_as_soon_as_allowed(self): @@ -275,7 +275,7 @@ class XModuleQuizAttemptsDelayTest(unittest.TestCase): ) # You should get a dialog that tells you to wait 2 minutes # Also, the number of attempts should not be incremented - self.assertRegexpMatches(result['success'], r"You must wait at least 2 hours between submissions. 2 minutes 1 second remaining\..*") + self.assertRegex(result['success'], r"You must wait at least 2 hours between submissions. 2 minutes 1 second remaining\..*") self.assertEqual(module.attempts, num_attempts) def test_submit_quiz_with_involved_pretty_print(self): @@ -289,7 +289,7 @@ class XModuleQuizAttemptsDelayTest(unittest.TestCase): ) # You should get a dialog that tells you to wait 2 minutes # Also, the number of attempts should not be incremented - self.assertRegexpMatches(result['success'], r"You must wait at least 2 hours 1 minute 3 seconds between submissions. 1 hour 2 minutes 59 seconds remaining\..*") + self.assertRegex(result['success'], r"You must wait at least 2 hours 1 minute 3 seconds between submissions. 1 hour 2 minutes 59 seconds remaining\..*") self.assertEqual(module.attempts, num_attempts) def test_submit_quiz_with_nonplural_pretty_print(self): @@ -303,5 +303,5 @@ class XModuleQuizAttemptsDelayTest(unittest.TestCase): ) # You should get a dialog that tells you to wait 2 minutes # Also, the number of attempts should not be incremented - self.assertRegexpMatches(result['success'], r"You must wait at least 1 minute between submissions. 1 minute remaining\..*") + self.assertRegex(result['success'], r"You must wait at least 1 minute between submissions. 1 minute remaining\..*") self.assertEqual(module.attempts, num_attempts) diff --git a/common/lib/xmodule/xmodule/tests/test_export.py b/common/lib/xmodule/xmodule/tests/test_export.py index 15c9ad4c5a..c0235a049b 100644 --- a/common/lib/xmodule/xmodule/tests/test_export.py +++ b/common/lib/xmodule/xmodule/tests/test_export.py @@ -104,7 +104,7 @@ class RoundTripTestCase(unittest.TestCase): initial_import = XMLModuleStore(root_dir, source_dirs=[course_dir], xblock_mixins=(XModuleMixin,)) courses = initial_import.get_courses() - self.assertEquals(len(courses), 1) + self.assertEqual(len(courses), 1) initial_course = courses[0] # export to the same directory--that way things like the custom_tags/ folder @@ -122,7 +122,7 @@ class RoundTripTestCase(unittest.TestCase): second_import = XMLModuleStore(root_dir, source_dirs=[course_dir], xblock_mixins=(XModuleMixin,)) courses2 = second_import.get_courses() - self.assertEquals(len(courses2), 1) + self.assertEqual(len(courses2), 1) exported_course = courses2[0] print("Checking course equality") @@ -133,7 +133,7 @@ class RoundTripTestCase(unittest.TestCase): strip_filenames(exported_course) self.assertTrue(blocks_are_equivalent(initial_course, exported_course)) - self.assertEquals(initial_course.id, exported_course.id) + self.assertEqual(initial_course.id, exported_course.id) course_id = initial_course.id print("Checking key equality") @@ -224,7 +224,7 @@ class TestEdxJsonEncoder(unittest.TestCase): unicode_text = u"Your 𝓟𝓵𝓪𝓽𝓯𝓸𝓻𝓶 Name Here" lazy_text = ugettext_lazy(unicode_text) - self.assertEquals( + self.assertEqual( unicode_text, self.encoder.default(lazy_text) ) diff --git a/common/lib/xmodule/xmodule/tests/test_fields.py b/common/lib/xmodule/xmodule/tests/test_fields.py index fef52e268d..e5a2a5bedc 100644 --- a/common/lib/xmodule/xmodule/tests/test_fields.py +++ b/common/lib/xmodule/xmodule/tests/test_fields.py @@ -222,7 +222,7 @@ class RelativeTimeTest(unittest.TestCase): ) error_msg = "RelativeTime max value is 23:59:59=86400.0 seconds, but 90000.0 seconds is passed" - with self.assertRaisesRegexp(ValueError, error_msg): + with self.assertRaisesRegex(ValueError, error_msg): RelativeTimeTest.delta.to_json(datetime.timedelta(seconds=90000)) with self.assertRaises(TypeError): diff --git a/common/lib/xmodule/xmodule/tests/test_graders.py b/common/lib/xmodule/xmodule/tests/test_graders.py index f69b8b90bb..eee3c8b5dc 100644 --- a/common/lib/xmodule/xmodule/tests/test_graders.py +++ b/common/lib/xmodule/xmodule/tests/test_graders.py @@ -406,7 +406,7 @@ class ShowCorrectnessTest(unittest.TestCase): due_date = None else: due_date = getattr(self, due_date_str) - self.assertEquals( + self.assertEqual( ShowCorrectness.correctness_available(ShowCorrectness.PAST_DUE, due_date, has_staff_access), expected_result ) diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py index 5c91d5ad29..f8a3b7686d 100644 --- a/common/lib/xmodule/xmodule/tests/test_import.py +++ b/common/lib/xmodule/xmodule/tests/test_import.py @@ -77,7 +77,7 @@ class BaseCourseTestCase(TestCase): xblock_select=only_xmodules, ) courses = modulestore.get_courses() - self.assertEquals(len(courses), 1) + self.assertEqual(len(courses), 1) return courses[0] @@ -522,7 +522,7 @@ class ImportTestCase(BaseCourseTestCase): # Not using get_courses because we need the modulestore object too afterward modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy']) courses = modulestore.get_courses() - self.assertEquals(len(courses), 1) + self.assertEqual(len(courses), 1) course = courses[0] print("course errors:") @@ -531,20 +531,20 @@ class ImportTestCase(BaseCourseTestCase): print(err) chapters = course.get_children() - self.assertEquals(len(chapters), 5) + self.assertEqual(len(chapters), 5) ch2 = chapters[1] - self.assertEquals(ch2.url_name, "secret:magic") + self.assertEqual(ch2.url_name, "secret:magic") print("Ch2 location: ", ch2.location) also_ch2 = modulestore.get_item(ch2.location) - self.assertEquals(ch2, also_ch2) + self.assertEqual(ch2, also_ch2) print("making sure html loaded") loc = course.id.make_usage_key('html', 'secret:toylab') html = modulestore.get_item(loc) - self.assertEquals(html.display_name, "Toy lab") + self.assertEqual(html.display_name, "Toy lab") def test_unicode(self): """Check that courses with unicode characters in filenames and in @@ -556,7 +556,7 @@ class ImportTestCase(BaseCourseTestCase): print("Starting import") modulestore = XMLModuleStore(DATA_DIR, source_dirs=['test_unicode']) courses = modulestore.get_courses() - self.assertEquals(len(courses), 1) + self.assertEqual(len(courses), 1) course = courses[0] print("course errors:") diff --git a/common/lib/xmodule/xmodule/tests/test_lti20_unit.py b/common/lib/xmodule/xmodule/tests/test_lti20_unit.py index 98c99e531f..6fdf3457f9 100644 --- a/common/lib/xmodule/xmodule/tests/test_lti20_unit.py +++ b/common/lib/xmodule/xmodule/tests/test_lti20_unit.py @@ -55,7 +55,7 @@ class LTI20RESTResultServiceTest(LogicTest): """ Input with bad content type """ - with self.assertRaisesRegexp(LTIError, "Content-Type must be"): + with self.assertRaisesRegex(LTIError, "Content-Type must be"): request = Mock(headers={u'Content-Type': u'Non-existent'}) self.xmodule.verify_lti_2_0_result_rest_headers(request) @@ -65,7 +65,7 @@ class LTI20RESTResultServiceTest(LogicTest): """ err_msg = "OAuth body verification failed" self.xmodule.verify_oauth_body_sign = Mock(side_effect=LTIError(err_msg)) - with self.assertRaisesRegexp(LTIError, err_msg): + with self.assertRaisesRegex(LTIError, err_msg): request = Mock(headers={u'Content-Type': u'application/vnd.ims.lis.v2.result+json'}) self.xmodule.verify_lti_2_0_result_rest_headers(request) @@ -98,7 +98,7 @@ class LTI20RESTResultServiceTest(LogicTest): fit the form user/ """ for einput in self.BAD_DISPATCH_INPUTS: - with self.assertRaisesRegexp(LTIError, "No valid user id found in endpoint URL"): + with self.assertRaisesRegex(LTIError, "No valid user id found in endpoint URL"): self.xmodule.parse_lti_2_0_handler_suffix(einput) GOOD_DISPATCH_INPUTS = [ @@ -159,7 +159,7 @@ class LTI20RESTResultServiceTest(LogicTest): """ for error_inputs, error_message in self.BAD_JSON_INPUTS: for einput in error_inputs: - with self.assertRaisesRegexp(LTIError, error_message): + with self.assertRaisesRegex(LTIError, error_message): self.xmodule.parse_lti_2_0_result_json(einput) GOOD_JSON_INPUTS = [ diff --git a/common/lib/xmodule/xmodule/tests/test_randomize_module.py b/common/lib/xmodule/xmodule/tests/test_randomize_module.py index ae19ed16e4..e2ef6d1a55 100644 --- a/common/lib/xmodule/xmodule/tests/test_randomize_module.py +++ b/common/lib/xmodule/xmodule/tests/test_randomize_module.py @@ -75,7 +75,7 @@ class RandomizeModuleTestCase(unittest.TestCase): """ Check course/randomize module works fine """ self.assertTrue(self.course.has_children) - self.assertEquals(len(self.course.get_children()), 2) + self.assertEqual(len(self.course.get_children()), 2) def inner_get_module(descriptor): """ @@ -95,7 +95,7 @@ class RandomizeModuleTestCase(unittest.TestCase): # Get randomize_descriptor from the course & verify its children randomize_descriptor = inner_get_module(self.course.id.make_usage_key('randomize', 'my_randomize')) self.assertTrue(randomize_descriptor.has_children) - self.assertEquals(len(randomize_descriptor.get_children()), 2) + self.assertEqual(len(randomize_descriptor.get_children()), 2) # Call RandomizeModule which will select an element from the list of available items randomize_module = RandomizeModule( @@ -105,5 +105,5 @@ class RandomizeModuleTestCase(unittest.TestCase): ) # Verify the selected child - self.assertEquals(len(randomize_module.get_child_descriptors()), 1, "No child is chosen") + self.assertEqual(len(randomize_module.get_child_descriptors()), 1, "No child is chosen") self.assertIn(randomize_module.child.display_name, ['A', 'B'], "Unwanted child selected") diff --git a/common/lib/xmodule/xmodule/tests/test_sequence.py b/common/lib/xmodule/xmodule/tests/test_sequence.py index 3dc8eda361..d75f4b5d99 100644 --- a/common/lib/xmodule/xmodule/tests/test_sequence.py +++ b/common/lib/xmodule/xmodule/tests/test_sequence.py @@ -129,7 +129,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest): def test_student_view_init(self): seq_module = SequenceModule(runtime=Mock(position=2), descriptor=Mock(), scope_ids=Mock()) - self.assertEquals(seq_module.position, 2) # matches position set in the runtime + self.assertEqual(seq_module.position, 2) # matches position set in the runtime @ddt.unpack @ddt.data( diff --git a/common/lib/xmodule/xmodule/tests/test_split_test_module.py b/common/lib/xmodule/xmodule/tests/test_split_test_module.py index f0b71aff96..05daf03aa2 100644 --- a/common/lib/xmodule/xmodule/tests/test_split_test_module.py +++ b/common/lib/xmodule/xmodule/tests/test_split_test_module.py @@ -141,7 +141,7 @@ class SplitTestModuleLMSTest(SplitTestModuleTest): @ddt.unpack def test_child(self, user_tag, child_url_name): self.user_partition.scheme.current_group = self.user_partition.groups[user_tag] - self.assertEquals(self.split_test_module.child_descriptor.url_name, child_url_name) + self.assertEqual(self.split_test_module.child_descriptor.url_name, child_url_name) @ddt.data((0, 'HTML FOR GROUP 0'), (1, 'HTML FOR GROUP 1')) @ddt.unpack @@ -162,7 +162,7 @@ class SplitTestModuleLMSTest(SplitTestModuleTest): # If a user_tag has a missing value, a group should be saved/persisted for that user. # So, we check that we get the same url_name when we call on the url_name twice. # We run the test ten times so that, if our storage is failing, we'll be most likely to notice it. - self.assertEquals( + self.assertEqual( self.split_test_module.child_descriptor.url_name, self.split_test_module.child_descriptor.url_name ) @@ -181,14 +181,14 @@ class SplitTestModuleLMSTest(SplitTestModuleTest): # Write out the xml. xml_obj = self.split_test_module.definition_to_xml(MemoryFS()) - self.assertEquals(xml_obj.get('user_partition_id'), '0') + self.assertEqual(xml_obj.get('user_partition_id'), '0') self.assertIsNotNone(xml_obj.get('group_id_to_child')) # Read the xml back in. fields, children = SplitTestDescriptor.definition_from_xml(xml_obj, self.module_system) - self.assertEquals(fields.get('user_partition_id'), '0') + self.assertEqual(fields.get('user_partition_id'), '0') self.assertIsNotNone(fields.get('group_id_to_child')) - self.assertEquals(len(children), 2) + self.assertEqual(len(children), 2) class SplitTestModuleStudioTest(SplitTestModuleTest): diff --git a/common/lib/xmodule/xmodule/tests/test_video.py b/common/lib/xmodule/xmodule/tests/test_video.py index 2246cb6106..6e010c3459 100644 --- a/common/lib/xmodule/xmodule/tests/test_video.py +++ b/common/lib/xmodule/xmodule/tests/test_video.py @@ -280,7 +280,7 @@ class VideoBlockImportTestCase(TestCase): Assert that `video` has the correct attributes. `attrs` is a map of {metadata_field: value}. """ for key, value in attrs.items(): - self.assertEquals(getattr(video, key), value) + self.assertEqual(getattr(video, key), value) def test_constructor(self): sample_xml = ''' @@ -820,7 +820,7 @@ class VideoExportTestCase(VideoBlockTestBase): xml = self.descriptor.definition_to_xml(self.file_system) # Check that download_video field is also set to default (False) in xml for backward compatibility expected = '