Skip to content

Commit

Permalink
skip svg ref tests on 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Feb 14, 2022
1 parent 43980ce commit d8b104d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import hashlib
import os
import pathlib
import sys
from typing import Callable, List
from xml.dom import minidom
from xml.etree import ElementTree
Expand Down Expand Up @@ -133,7 +134,9 @@ def _assert_image_similarity(img: Image) -> None:

def _read_SVG_lines(path: pathlib.Path) -> List[str]:
tree = ElementTree.parse(path)
canon = ElementTree.canonicalize(ElementTree.tostring(tree.getroot()), strip_text=True)
xml_str = ElementTree.tostring(tree.getroot())
# ET.canonicalize doesn't exist on Python 3.7
canon = ElementTree.canonicalize(xml_str, strip_text=True) # type: ignore
lines = minidom.parseString(canon).toprettyxml().splitlines()
return [line for line in lines if "<dc:source" not in line and "<dc:date" not in line]

Expand All @@ -150,6 +153,10 @@ def test_ref_svg(reference_svg):
with reference_svg() as path:
export_svg_to(path)
"""

if sys.version_info < (3, 8):
pytest.skip("requires Python 3.8 or higher")

store_ref_svg = request.config.getoption("--store-ref-svg")
test_id = "refsvg_" + hashlib.md5(request.node.name.encode()).hexdigest() + ".svg"
ref_path = pathlib.Path(REFERENCE_IMAGES_DIR) / test_id
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d8b104d

Please sign in to comment.