From a9611ba80bc5196c1dd07a0b1964fcb603695d63 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 12 Dec 2021 15:23:49 +0100 Subject: [PATCH] Fix a test in Py2. --- src/lxml/html/tests/test_clean.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lxml/html/tests/test_clean.py b/src/lxml/html/tests/test_clean.py index aec87cd9e..2c785f563 100644 --- a/src/lxml/html/tests/test_clean.py +++ b/src/lxml/html/tests/test_clean.py @@ -1,5 +1,6 @@ import base64 import gzip +import io import unittest from lxml.tests.common_imports import make_doctest @@ -188,7 +189,11 @@ def test_sneaky_urls_in_style(self): def test_svg_data_links(self): # Remove SVG images with potentially insecure content. svg = b'' - svgz = gzip.compress(svg) + gzout = io.BytesIO() + f = gzip.GzipFile(fileobj=gzout, mode='wb') + f.write(svg) + f.close() + svgz = gzout.getvalue() svg_b64 = base64.b64encode(svg).decode('ASCII') svgz_b64 = base64.b64encode(svgz).decode('ASCII') urls = [