fix(tests): compare Pygments HTML output semantically across 2.19–2.21 - #10642
Conversation
Pygments 2.21 emits literal quotes in HTML text nodes while earlier versions use entities, which broke three tests that compared exact encodings. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
Pull request overview
This PR adjusts test assertions and snapshot comparisons to be robust across Pygments 2.19–2.21 HTML escaping differences (notably quote entity encoding), so CI remains compatible with the declared pygments>=2.19,<3 range without pinning to <2.21.
Changes:
- Added an HTML-entity normalization helper and applied it in snapshot normalization.
- Relaxed embed-trace assertions to be less sensitive to quote encoding.
- Updated markdown code-block HTML assertion to compare normalized output rather than exact entity encoding.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/mocks.py | Introduces normalize_html_entities() and applies it during snapshot normalization. |
| tests/_runtime/test_trace.py | Loosens traceback assertions to avoid dependence on HTML quote entity encoding. |
| tests/_output/test_md.py | Normalizes Pygments-generated HTML before asserting equality for code blocks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Narrow entity normalization to quotes only, skip JSON snapshots, and assert traceback path and line number appear together after normalization. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/_output/test_md.py">
<violation number="1" location="tests/_output/test_md.py:42">
P2: This broad normalization can let double-encoded or incorrectly escaped code pass the test. Normalize only the quote entity spellings that differ across Pygments versions, or compare parsed HTML text nodes while preserving entity semantics.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Summary
'/") instead of entity-encoded forms ('/").normalize_html_entities()intests/mocks.py(repeatedhtml.unescape) and use it in snapshot comparisons and markdown code-block assertions.This unblocks CI for PR #10618 and keeps compatibility with the declared
pygments>=2.19,<3range without pinning below 2.21.Test plan
tests/_islands/snapshots/markdown.txtwas not updatedruff checkon changed filesMade with Cursor