Skip to content

Commit a9611ba

Browse files
committed
Fix a test in Py2.
1 parent a3eacbc commit a9611ba

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/lxml/html/tests/test_clean.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import base64
22
import gzip
3+
import io
34
import unittest
45
from lxml.tests.common_imports import make_doctest
56

@@ -188,7 +189,11 @@ def test_sneaky_urls_in_style(self):
188189
def test_svg_data_links(self):
189190
# Remove SVG images with potentially insecure content.
190191
svg = b'<svg onload="alert(123)" />'
191-
svgz = gzip.compress(svg)
192+
gzout = io.BytesIO()
193+
f = gzip.GzipFile(fileobj=gzout, mode='wb')
194+
f.write(svg)
195+
f.close()
196+
svgz = gzout.getvalue()
192197
svg_b64 = base64.b64encode(svg).decode('ASCII')
193198
svgz_b64 = base64.b64encode(svgz).decode('ASCII')
194199
urls = [

0 commit comments

Comments
 (0)