[woff2_test] adjust 'test_incorrect_compressed_size' to make it work with brotlipy

In the upstream google/brotli, if the `decompress` function receives an empty byte
string, it returns a brotli.error; whereas in 'brotlipy' it does not raise but
returns an empty string b"":
https://github.com/python-hyper/brotlipy/issues/43#issuecomment-240378257

This test case asserts that when 'totalCompressedSize' in the WOFF2 header is
incorrectly set, the woff2 reader fails -- either because the brotli decoder
raises an exception, or it returns a string whose length is not the one expected.
This commit is contained in:
Cosimo Lupo 2016-08-17 12:07:02 +01:00
parent 3ddc1f2fee
commit 855c3b17c9

View File

@ -79,7 +79,7 @@ class WOFF2ReaderTest(unittest.TestCase):
header = sstruct.unpack(woff2DirectoryFormat, data)
header['totalCompressedSize'] = 0
data = sstruct.pack(woff2DirectoryFormat, header)
with self.assertRaises(brotli.error):
with self.assertRaises((brotli.error, ttLib.TTLibError)):
WOFF2Reader(BytesIO(data + self.file.read()))
def test_incorrect_uncompressed_size(self):