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" ")")
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 ')
def test_bytes(): pformat_ = PrettyFormat(width=12) v = pformat_(string.ascii_lowercase.encode()) assert v == """(
def test_str_repr(): pformat_ = PrettyFormat(repr_strings=True) v = pformat_(string.ascii_lowercase + '\n' + string.digits) assert v == "'abcdefghijklmnopqrstuvwxyz\\n0123456789'"
def test_bytearray(): pformat_ = PrettyFormat(width=18) v = pformat_(bytearray(string.ascii_lowercase.encode())) assert v == """\