mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Call repr() when pretty() fails in _pprint_displayhook
This commit is contained in:
parent
40352638bf
commit
d41e6ddf72
2 changed files with 26 additions and 1 deletions
23
news/print-mocks-correctly.rst
Normal file
23
news/print-mocks-correctly.rst
Normal file
|
@ -0,0 +1,23 @@
|
|||
**Added:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Changed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* Viewing mock objects in the shell
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -251,9 +251,11 @@ def _pprint_displayhook(value):
|
|||
builtins._ = value
|
||||
return
|
||||
env = builtins.__xonsh__.env
|
||||
printed_val = None
|
||||
if env.get("PRETTY_PRINT_RESULTS"):
|
||||
printed_val = pretty(value)
|
||||
else:
|
||||
if not isinstance(printed_val, str):
|
||||
# pretty may fail (i.e for unittest.mock.Mock)
|
||||
printed_val = repr(value)
|
||||
if HAS_PYGMENTS and env.get("COLOR_RESULTS"):
|
||||
tokens = list(pygments.lex(printed_val, lexer=pyghooks.XonshLexer()))
|
||||
|
|
Loading…
Add table
Reference in a new issue