From 5c40a3729a288033f1e579a41cbaf5bd8dfd4096 Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Thu, 2 Apr 2020 11:06:37 -0400 Subject: [PATCH] Stop using deprecated assertions (#23579) Replace some usage of deprecated assertions with non-deprecated equivalents. --- common/djangoapps/edxmako/tests.py | 8 +++--- .../capa/capa/tests/test_targeted_feedback.py | 28 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/common/djangoapps/edxmako/tests.py b/common/djangoapps/edxmako/tests.py index 37eaa24a89..1ef7b2449a 100644 --- a/common/djangoapps/edxmako/tests.py +++ b/common/djangoapps/edxmako/tests.py @@ -79,11 +79,11 @@ class ShortcutsTests(UrlResetMixin, TestCase): # test marketing site on with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): link = marketing_link('TOS') - 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}): link = marketing_link('TOS') - self.assertEquals(link, expected_link) + self.assertEqual(link, expected_link) @override_settings(MKTG_URLS={'ROOT': 'https://dummy-root', 'TOS': '/tos'}) @override_settings(MKTG_URL_OVERRIDES={'TOS': '123456'}) @@ -92,11 +92,11 @@ class ShortcutsTests(UrlResetMixin, TestCase): # test marketing site on with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): link = marketing_link('TOS') - 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}): link = marketing_link('TOS') - self.assertEquals(link, expected_link) + self.assertEqual(link, expected_link) class AddLookupTests(TestCase): diff --git a/common/lib/capa/capa/tests/test_targeted_feedback.py b/common/lib/capa/capa/tests/test_targeted_feedback.py index 5bc6cb42c1..bf30a8535b 100644 --- a/common/lib/capa/capa/tests/test_targeted_feedback.py +++ b/common/lib/capa/capa/tests/test_targeted_feedback.py @@ -90,7 +90,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): without_new_lines = the_html.replace("\n", "") 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.assertNotRegex(without_new_lines, r"feedback1|feedback2|feedback3|feedbackC") self.assertEqual(the_html, problem.get_html(), "Should be able to call get_html() twice") def test_targeted_feedback_student_answer1(self): @@ -102,7 +102,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): without_new_lines = the_html.replace("\\n", "").replace("\n", "") # pylint: disable=line-too-long self.assertRegex(without_new_lines, r"\s*Incorrect.*3rd WRONG solution") - self.assertNotRegexpMatches(without_new_lines, r"feedback1|feedback2|feedbackC") + self.assertNotRegex(without_new_lines, r"feedback1|feedback2|feedbackC") # Check that calling it multiple times yields the same thing the_html2 = problem.get_html() self.assertEqual(the_html, the_html2) @@ -117,7 +117,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): # pylint: disable=line-too-long 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") + self.assertNotRegex(without_new_lines, r"feedback2|feedback3|feedbackC") def test_targeted_feedback_correct_answer(self): """ Test the case of targeted feedback for a correct answer. """ @@ -130,7 +130,7 @@ class CapaTargetedFeedbackTest(unittest.TestCase): # pylint: disable=line-too-long self.assertRegex(without_new_lines, r"\s*Correct.*Feedback on your correct solution...") - self.assertNotRegexpMatches(without_new_lines, r"feedback1|feedback2|feedback3") + self.assertNotRegex(without_new_lines, r"feedback1|feedback2|feedback3") def test_targeted_feedback_id_typos(self): """Cases where the explanation-id's don't match anything.""" @@ -300,8 +300,8 @@ class CapaTargetedFeedbackTest(unittest.TestCase): # pylint: disable=line-too-long self.assertRegex(without_new_lines, r".*1st WRONG solution") self.assertRegex(without_new_lines, r"\{.*'1_solution_1'.*\}") - self.assertNotRegexpMatches(without_new_lines, r"feedback2|feedback3") + self.assertNotRegex(without_new_lines, r"
\{.*'1_solution_1'.*\}
") + self.assertNotRegex(without_new_lines, r"feedback2|feedback3") # Check that calling it multiple times yields the same thing the_html2 = problem.get_html() self.assertEqual(the_html, the_html2) @@ -369,9 +369,9 @@ class CapaTargetedFeedbackTest(unittest.TestCase): without_new_lines = the_html.replace("\n", "") # pylint: disable=line-too-long self.assertRegex(without_new_lines, r".*1st WRONG solution") - self.assertNotRegexpMatches(without_new_lines, r"\{.*'1_solution_1'.*\}") - self.assertNotRegexpMatches(without_new_lines, r"feedback2|feedback3|feedbackC") + self.assertNotRegex(without_new_lines, r"feedback2|feedback3|feedbackC") def test_targeted_feedback_with_solutionset_explanation(self): xml_str = textwrap.dedent(""" @@ -447,8 +447,8 @@ class CapaTargetedFeedbackTest(unittest.TestCase): # pylint: disable=line-too-long self.assertRegex(without_new_lines, r".*1st WRONG solution") self.assertRegex(without_new_lines, r"\{.*'1_solution_1'.*\}") - self.assertNotRegexpMatches(without_new_lines, r"feedback2|feedback3") + self.assertNotRegex(without_new_lines, r"
\{.*'1_solution_1'.*\}
") + self.assertNotRegex(without_new_lines, r"feedback2|feedback3") def test_targeted_feedback_no_feedback_for_selected_choice1(self): xml_str = textwrap.dedent(""" @@ -510,8 +510,8 @@ class CapaTargetedFeedbackTest(unittest.TestCase): without_new_lines = the_html.replace("\n", "") self.assertRegex(without_new_lines, r"\{.*'1_solution_1'.*\}") - self.assertNotRegexpMatches(without_new_lines, r"feedback1|feedback3") + self.assertNotRegex(without_new_lines, r"
\{.*'1_solution_1'.*\}
") + self.assertNotRegex(without_new_lines, r"feedback1|feedback3") def test_targeted_feedback_no_feedback_for_selected_choice2(self): xml_str = textwrap.dedent(""" @@ -571,9 +571,9 @@ class CapaTargetedFeedbackTest(unittest.TestCase): the_html = problem.get_html() without_new_lines = the_html.replace("\n", "") - self.assertNotRegexpMatches(without_new_lines, r"\{.*'1_solution_1'.*\}") - self.assertNotRegexpMatches(without_new_lines, r"feedback1|feedback3|feedbackC") + self.assertNotRegex(without_new_lines, r"feedback1|feedback3|feedbackC") def test_targeted_feedback_multiple_not_answered(self): # Not answered -> empty targeted feedback