[issue27432] Unittest truncating of error message not works

Camilla Ke report at bugs.python.org
Fri Jul 1 05:27:49 EDT 2016


New submission from Camilla Ke:

Builtin assert methods output messages no matter how length is the output messages.

However, content with exceeding length should be truncated.  

I found an error in the function.

The function is safe_repr() in util.py

if len(result) > _MAX_LENGTH, it should return truncated content, but "short" is default to False. 

unittest/util.py
def safe_repr(obj, short=False):
    try:
        result = repr(obj)
    except Exception:
        result = object.__repr__(obj)
    if not short or len(result) < _MAX_LENGTH:
        return result
    return result[:_MAX_LENGTH] + ' [truncated]...'

----------
components: Library (Lib)
messages: 269653
nosy: Camilla Ke
priority: normal
severity: normal
status: open
title: Unittest truncating of error message not works
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27432>
_______________________________________


More information about the Python-bugs-list mailing list