Issue: Pytest Subtest Output Not Highlighted Correctly by Pygments Pytest Lexer
Summary
When using the pytest lexer in Pygments, certain forms of pytest output, especially subtest failure block, are not tokenized or highlighted correctly. This leads to inaccurate styling when rendered in downstream tools such as pytest documentation, the pytest website, and other Sphinx-generated docs.
What's Happening
In particular, the lexer does not correctly detect or tokenize:
FAILED Subtest:blocks- Indentation/continuation lines within subtest output
- Stack traces inside subtest reports
- Error-summary formatting that appears after subtests
As a result, rendering shows either:
- Missing color highlighting
- Entire blocks treated as plain text
Expected Behaviour
The pytest lexer should correctly highlight subtest output in the same way it highlights standard pytest failure reports, for example:
- Headers (
FAILED,E, etc.) should use the same error tokens - Subtest detail lines should inherit traceback/summary highlighting
- Continuation blocks should follow pytest’s existing multiline output rules
This would ensure that:
- Documentation examples remain consistently highlighted
- Pytest output is parsed as expected across tools