Skip to content

🐛 fix(pretty-printer): keep the parent icon when indenting - #322

Merged
gaborbernat merged 2 commits into
pytest-dev:mainfrom
mk78:mk78-investigate-printer-defect
Dec 4, 2026
Merged

gaborbernat merged 2 commits into
pytest-dev:mainfrom
mk78:mk78-investigate-printer-defect

Conversation

@mk78

@mk78 mk78 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

The README says the pretty_printer fixture can create a printer one level deeper that optionally uses a different icon, but indent() required icon and raised TypeError without it. 🐛 icon is now optional: left out, the indented printer keeps its parent's icon, ⏩ for the fixture itself, so a chain of indent() calls carries the icon down, and a given icon still replaces it, as it already does for a single message.

$ cat test_it.py
def test_output(pretty_printer):
    pretty_printer.indent(icon="🚀").indent()("indented")
$ pytest -q --print test_it.py
-E       TypeError: _PrettyPrinter.indent() missing 1 required keyword-only argument: 'icon'
-FAILED test_it.py::test_output - TypeError: _PrettyPrinter.indent() missing 1...
-1 failed in 0.01s
+         🚀 indented
+1 passed in 0.00s

mk78 and others added 2 commits December 4, 2026 10:07
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Indenting from the default printer passed even if indent() ignored its
parent and used the default icon, so the test now indents twice from a
parent with its own icon. The changelog fragment gains the + prefix the
other issue-less fragments use, and the indent docstring stops promising
the given icon.
@gaborbernat gaborbernat changed the title Fix pretty printer icon inheritance when indenting 🐛 fix(pretty-printer): keep the parent icon when indenting Dec 4, 2026
@gaborbernat gaborbernat added the bug Something isn't working label Dec 4, 2026
@gaborbernat
gaborbernat merged commit ffed36c into pytest-dev:main Dec 4, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants