From 1deb60037ed061c5dd973005b81c106561032ebe Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 25 Apr 2020 08:14:27 +0200 Subject: Improve lulua-write Introduce composable filters, switch to brotli-compressed tarballs, which has good ratios and fast decompression, reducing I/O significantly. --- lulua/test_text.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lulua/test_text.py') diff --git a/lulua/test_text.py b/lulua/test_text.py index 65aa3a1..cd8ae7a 100644 --- a/lulua/test_text.py +++ b/lulua/test_text.py @@ -18,7 +18,10 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -from .text import charMap, mapChars +import brotli +from io import BytesIO + +from .text import charMap, mapChars, BrotliFile def test_map_chars_mapped (): """ Make sure all chars in the map are mapped correctly """ @@ -46,3 +49,12 @@ def test_map_chars_not_mapped (): outText = mapChars (inText, charMap) assert outText == expectText +def test_brotlifile (): + compressed = brotli.compress (b'hello world') + for chunk in (1, 2, 3, 1024, None): + f = BrotliFile (BytesIO (compressed), chunk) + s = f.read (1) + assert s == b'h' + s = f.read () + assert s == b'ello world' + -- cgit v1.2.3