コード例 #1
0
def test_str():
    pformat_ = PrettyFormat(width=12)
    v = pformat_(string.ascii_lowercase + '\n' + string.digits)
    print(repr(v))
    assert v == ("(\n"
                 "    'abcde'\n"
                 "    'fghij'\n"
                 "    'klmno'\n"
                 "    'pqrst'\n"
                 "    'uvwxy'\n"
                 "    'z\\n"
                 "'\n"
                 "    '01234'\n"
                 "    '56789'\n"
                 ")")
コード例 #2
0
def test_generator_no_yield():
    pformat_ = PrettyFormat(yield_from_generators=False)
    v = pformat_((i for i in range(3)))
    assert v.startswith(
        '<generator object test_generator_no_yield.<locals>.<genexpr> at ')
コード例 #3
0
def test_bytes():
    pformat_ = PrettyFormat(width=12)
    v = pformat_(string.ascii_lowercase.encode())
    assert v == """(
コード例 #4
0
def test_str_repr():
    pformat_ = PrettyFormat(repr_strings=True)
    v = pformat_(string.ascii_lowercase + '\n' + string.digits)
    assert v == "'abcdefghijklmnopqrstuvwxyz\\n0123456789'"
コード例 #5
0
def test_bytearray():
    pformat_ = PrettyFormat(width=18)
    v = pformat_(bytearray(string.ascii_lowercase.encode()))
    assert v == """\