Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixed #36499 -- Adjusted utils_tests.test_html.TestUtilsHtml.test_strip_tags following Python's HTMLParser new behavior.#19639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
nessita wants to merge1 commit intodjango:main
base:main
Choose a base branch
Loading
fromnessita:ticket-36499

Conversation

nessita
Copy link
Contributor

@nessitanessita commentedJul 14, 2025
edited
Loading

🛑 Not to be merged before 3.13.6, 3.12.12, 3.11.14, 3.10.19 and 3.9.24 are released (and Jenkins CI gets updated).

Trac ticket number

ticket-36499

Branch description

As described in the ticket,Python's HTMLParser was adjusted to avoid poor performance on malformed HTML. This branch adjust the Django tests that were specifically added for performance related reports to follow Python's HTMLParser behavior.

Checklist

  • This PR targets themain branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.

@nessitanessita marked this pull request as draftJuly 14, 2025 17:53
@felixxm
Copy link
Member

There isone more failure intest_utils.tests.HTMLEqualTests.test_parsing_errors, it may be caused by the same change inHTMLParser.

@nessita
Copy link
ContributorAuthor

There isone more failure intest_utils.tests.HTMLEqualTests.test_parsing_errors, it may be caused by the same change inHTMLParser.

Yeah, I started fixing this test yesterday, and I've been trying to think what the right fix is, because is not straightforward. Before, this line:

self.assertHTMLEqual("< div></ div>","<div></div>")

would raise an AssertionError with message:

AssertionError: First argument is not valid HTML:('Unexpected end tag `div` (Line 1, Column 6)', (1, 6))

Now it fails with:

AssertionError: &lt; div&gt; != <div>- &lt; div&gt;+ <div>

I need to dig deeper to understand if the assertion message change is acceptable or not.

…ip_tags following Python's HTMLParser new behavior.
Comment on lines -962 to +965
"('Unexpected end tag `div` (Line 1, Column6)', (1,6))"
"('Unexpected end tag `div` (Line 1, Column0)', (1,0))"
)
with self.assertRaisesMessage(AssertionError, error_msg):
self.assertHTMLEqual("< div></div>", "<div></div>")
self.assertHTMLEqual("</div>", "<div></div>")
Copy link
Member

@cliff688cliff688Jul 16, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Since this is not aboutstrip_tags(), I think the commit message needs to be adjusted to show this. Also, maybe it doesn't really matter, or may allow the changes here to be split into 2 commits, but the changes toHTMLParser resulting in this test failure areunrelated to those causing failures instrip_tags()'s tests.

Additionally, I think we can change to:

diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.pyindex 494a0ea8d3..f2cfc55e2b 100644--- a/tests/test_utils/tests.py+++ b/tests/test_utils/tests.py@@ -962,7 +962,7 @@ class HTMLEqualTests(SimpleTestCase):             "('Unexpected end tag `div` (Line 1, Column 6)', (1, 6))"         )         with self.assertRaisesMessage(AssertionError, error_msg):-            self.assertHTMLEqual("< div></ div>", "<div></div>")+            self.assertHTMLEqual("< div></div>", "<div></div>")         with self.assertRaises(HTMLParseError):             parse_html("</p>")

with the advantage of a (marginally 🌞) smaller diff and a test for a non-zero column position in the message

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@cliff688cliff688cliff688 left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@nessita@felixxm@cliff688

[8]ページ先頭

©2009-2025 Movatter.jp