def test_truncate_message():
    suffix = "But it'll be truncated anyway."
    original = ("This isn't really that big.\n" * 1024) + suffix
    limit = len(suffix) + 3
    newmsg = _truncate_message(original, limit=len(suffix) + 3)
    assert len(newmsg) < limit + len(_TRUNCATION_HEADER)

    short = "Hello"
    assert short == _truncate_message(short, limit=1024)

    single_long_line = "Text " * 1024
    assert _truncate_message(single_long_line, limit=1024) == _TRUNCATION_HEADER

    # Because this was previously broken.
    assert _truncate_message(None, limit=1024) is None
dataset/ETHPy150Open dropbox/changes/tests/changes/artifacts/test_xunit.py/test_truncate_message/original