Skip to content

fix(tests): compare Pygments HTML output semantically across 2.19–2.21 - #10642

Merged
kirangadhave merged 2 commits into
mainfrom
kg/pygments-2.21-quote-tests
Aug 24, 2026
Merged

fix(tests): compare Pygments HTML output semantically across 2.19–2.21#10642
kirangadhave merged 2 commits into
mainfrom
kg/pygments-2.21-quote-tests

Conversation

@kirangadhave

Copy link
Copy Markdown
Member

Summary

  • Fix three backend test failures caused by Pygments 2.21 rendering quotes literally in HTML text nodes (' / ") instead of entity-encoded forms (' / ").
  • Add normalize_html_entities() in tests/mocks.py (repeated html.unescape) and use it in snapshot comparisons and markdown code-block assertions.
  • Relax embed-trace assertions to check traceback file path and line number semantically instead of exact quote encoding.

This unblocks CI for PR #10618 and keeps compatibility with the declared pygments>=2.19,<3 range without pinning below 2.21.

Test plan

  • Reproduced failures with Pygments 2.21.0 before the fix
  • Verified all three affected tests pass with isolated overlays:
    • Pygments 2.19.2
    • Pygments 2.20.0
    • Pygments 2.21.0
  • Confirmed tests/_islands/snapshots/markdown.txt was not updated
  • ruff check on changed files

Made with Cursor

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>
Copilot AI lite review requested due to automatic review settings August 24, 2026 18:21
@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview Aug 24, 2026 6:35pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread tests/mocks.py
Comment thread tests/mocks.py Outdated
Comment thread tests/_runtime/test_trace.py
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>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread tests/_output/test_md.py
@kirangadhave
kirangadhave merged commit ad02456 into main Aug 24, 2026
41 checks passed
@kirangadhave
kirangadhave deleted the kg/pygments-2.21-quote-tests branch August 24, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants