From 6eead791a1cc9ee938489f6a5ea31cd1d738c6fb Mon Sep 17 00:00:00 2001 From: mariajgrimaldi <64440265+mariajgrimaldi@users.noreply.github.com> Date: Fri, 8 May 2020 11:53:02 -0400 Subject: [PATCH] Fix DeprecationWarning: Please use assertNotRegex instead (#23907) I wanted to make a byte-sized contribution but there were no Jira tickets so we decided, thanks to a conversation with @jmbowman through the Open Edx Community #incr (Slack) channel, to collaborate in the elimination of warnings listed in the Warnings Report at https://build.testeng.edx.org/job/edx-platform-python-pipeline-master/warning_5freport_5fall_2ehtml/ This PR contributes to the elimination of deprecation warnings, specifically the one mentioned above and reported in the Warnings Report. Changed assertNotRegexpMatches to assertNotRegex in the following files: cms/djangoapps/contentstore/views/tests/test_preview.py cms/djangoapps/contentstore/views/tests/test_item.py lms/djangoapps/commerce/tests/test_views.py lms/djangoapps/dashboard/tests/test_sysadmin.py This warning occurs due to deprecation in python 3.5: https://docs.python.org/3.5/library/unittest.html#unittest.TestCase.assertNotRegex --- cms/djangoapps/contentstore/views/tests/test_item.py | 2 +- .../contentstore/views/tests/test_preview.py | 10 +++++----- lms/djangoapps/commerce/tests/test_views.py | 2 +- lms/djangoapps/dashboard/tests/test_sysadmin.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py index b4d9df1873..70226c47bd 100644 --- a/cms/djangoapps/contentstore/views/tests/test_item.py +++ b/cms/djangoapps/contentstore/views/tests/test_item.py @@ -208,7 +208,7 @@ class GetItemTest(ItemTest): # XBlock messages are added by the Studio wrapper. self.assertIn('wrapper-xblock-message', html) # Make sure that "wrapper-xblock" does not appear by itself (without -message at end). - self.assertNotRegexpMatches(html, r'wrapper-xblock[^-]+') + self.assertNotRegex(html, r'wrapper-xblock[^-]+') # Verify that the header and article tags are still added self.assertIn('
', html) diff --git a/cms/djangoapps/contentstore/views/tests/test_preview.py b/cms/djangoapps/contentstore/views/tests/test_preview.py index 5b82e04948..ce110e0425 100644 --- a/cms/djangoapps/contentstore/views/tests/test_preview.py +++ b/cms/djangoapps/contentstore/views/tests/test_preview.py @@ -70,13 +70,13 @@ class GetPreviewHtmlTestCase(ModuleStoreTestCase): 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[\"\']") + self.assertNotRegex(html, r"data-block-type=[\"\']acid_aside[\"\']") # Ensure about pages don't have asides about = modulestore().get_item(course.id.make_usage_key('about', 'overview')) html = get_preview_fragment(request, about, context).content - self.assertNotRegexpMatches(html, r"data-block-type=[\"\']test_aside[\"\']") - self.assertNotRegexpMatches(html, "Aside rendered") + self.assertNotRegex(html, r"data-block-type=[\"\']test_aside[\"\']") + self.assertNotRegex(html, "Aside rendered") @XBlockAside.register_temp_plugin(AsideTestType, 'test_aside') def test_preview_no_asides(self): @@ -106,8 +106,8 @@ class GetPreviewHtmlTestCase(ModuleStoreTestCase): } html = get_preview_fragment(request, html, context).content - self.assertNotRegexpMatches(html, r"data-block-type=[\"\']test_aside[\"\']") - self.assertNotRegexpMatches(html, "Aside rendered") + self.assertNotRegex(html, r"data-block-type=[\"\']test_aside[\"\']") + self.assertNotRegex(html, "Aside rendered") @mock.patch('xmodule.conditional_module.ConditionalModule.is_condition_satisfied') def test_preview_conditional_module_children_context(self, mock_is_condition_satisfied): diff --git a/lms/djangoapps/commerce/tests/test_views.py b/lms/djangoapps/commerce/tests/test_views.py index 628e86c700..47fd4240d7 100644 --- a/lms/djangoapps/commerce/tests/test_views.py +++ b/lms/djangoapps/commerce/tests/test_views.py @@ -130,7 +130,7 @@ class ReceiptViewTests(UserMixin, ModuleStoreTestCase): response.content.decode('utf-8'), user_message if is_user_message_expected else system_message ) - self.assertNotRegexpMatches( + self.assertNotRegex( response.content.decode('utf-8'), user_message if not is_user_message_expected else system_message ) diff --git a/lms/djangoapps/dashboard/tests/test_sysadmin.py b/lms/djangoapps/dashboard/tests/test_sysadmin.py index 4f42623eb2..d969063f0f 100644 --- a/lms/djangoapps/dashboard/tests/test_sysadmin.py +++ b/lms/djangoapps/dashboard/tests/test_sysadmin.py @@ -193,7 +193,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase): # Make sure we don't have any git hashes on the page response = self.client.get(reverse('sysadmin_courses')) - self.assertNotRegexpMatches(response.content.decode('utf-8'), table_re) + self.assertNotRegex(response.content.decode('utf-8'), table_re) # Now add the course and make sure it does match response = self._add_edx4edx()