From be20801294d8cece2aff6d8170f46f03c1047f10 Mon Sep 17 00:00:00 2001 From: mubbsharanwar Date: Fri, 15 Aug 2025 14:21:18 +0500 Subject: [PATCH] fix: fix test_html_tags_removal unescape "" from the html body. issue: 37198 --- .../tests/test_discussions_notifications.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lms/djangoapps/discussion/rest_api/tests/test_discussions_notifications.py b/lms/djangoapps/discussion/rest_api/tests/test_discussions_notifications.py index 5e0640c64e0e..247bd23540cf 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_discussions_notifications.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_discussions_notifications.py @@ -2,6 +2,7 @@ Unit tests for the DiscussionNotificationSender class """ import re +import django import unittest from unittest.mock import MagicMock, patch @@ -108,11 +109,14 @@ def test_html_tags_removal(self):

Script test:

Some other content that should remain.

""" - expected_output = ('

This is a link to a page.

' - '

Here is an image:

' - '

Embedded video:

' - '

Script test: alert("hello");

' - '

Some other content that should remain.

') + excepted_script_quot = 'alert("hello");' if django.VERSION >= (5, 0) else 'alert("hello");' + expected_output = ( + f'

This is a link to a page.

' + f'

Here is an image:

' + f'

Embedded video:

' + f'

Script test: {excepted_script_quot}

' + f'

Some other content that should remain.

' + ) result = clean_thread_html_body(html_body)