Skip to content

[BUG] Can't print MagicMock.mock_calls #903

@henryiii

Description

@henryiii

Describe the bug
rich.print does not print something that print does, breaking with:

NotRenderableError: Unable to render (<console width=93 ColorSystem.TRUECOLOR>, ConsoleOptions(legacy_windows=False, min_width=1, max_width=93, is_terminal=False, encoding='utf-8', justify=None, overflow=None, no_wrap=False, highlight=None)); A str, Segment or object with __rich_console__ method is required

To Reproduce

from unittest.mock import MagicMock

ListProxy = MagicMock("ListProxy")
y = ListProxy()
y[0] += 1
rich.print(*y.mock_calls)

If you remove the rich. or the *, it works. I'm assuming it is suppose to fall back to repr/str, or is it supposed to break? The list containing it works just fine, just not singled out. This is a fairly unusual thing to print, I know, was working on a tutorial.

Platform

macOS 11 Intel, normally iTerm2 though I was in JupyterLab 3 for this, 9.7.0 from conda-forge.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions