()
| 80 | |
| 81 | |
| 82 | def test_is_mostly_bin(): |
| 83 | assert not strutils.is_mostly_bin(b"foo\xff") |
| 84 | assert strutils.is_mostly_bin(b"foo" + b"\xff" * 10) |
| 85 | assert not strutils.is_mostly_bin(b"") |
| 86 | assert strutils.is_mostly_bin(b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09") |
| 87 | # shift UTF8 break point |
| 88 | # 𐍅 is four bytes in UTF-8, so we're breaking the 100 chars barrier. |
| 89 | assert not strutils.is_mostly_bin(b"" + 50 * "𐍅".encode()) |
| 90 | assert not strutils.is_mostly_bin(b"a" + 50 * "𐍅".encode()) |
| 91 | assert not strutils.is_mostly_bin(b"aa" + 50 * "𐍅".encode()) |
| 92 | assert not strutils.is_mostly_bin(b"aaa" + 50 * "𐍅".encode()) |
| 93 | assert not strutils.is_mostly_bin(b"aaaa" + 50 * "𐍅".encode()) |
| 94 | assert not strutils.is_mostly_bin(b"aaaaa" + 50 * "𐍅".encode()) |
| 95 | # only utf8 continuation chars |
| 96 | assert strutils.is_mostly_bin(150 * b"\x80") |
| 97 | # regression #8188: payloads with len 101-103 and a continuation byte at |
| 98 | # the 100-byte cutoff used to raise IndexError because the lookahead loop |
| 99 | # ran past the end of the string. Should not raise. |
| 100 | for tail in (1, 2, 3): |
| 101 | strutils.is_mostly_bin(b"a" * 100 + b"\x80" * tail) |
| 102 | |
| 103 | |
| 104 | def test_is_xml(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…