diff --git a/qurator/mods4pandas/tests/test_page_info.py b/qurator/mods4pandas/tests/test_page_info.py index 441230b..a740ffd 100644 --- a/qurator/mods4pandas/tests/test_page_info.py +++ b/qurator/mods4pandas/tests/test_page_info.py @@ -1,3 +1,4 @@ +import sys from pathlib import Path from lxml import etree as ET @@ -8,6 +9,13 @@ from qurator.mods4pandas.mods4pandas import pages_to_dict TESTS_DATA_DIR = Path(__file__).parent / "data" +def removeprefix(s, prefix): + if sys.version_info < (3,9): + return s[len(prefix):] if s.startswith(prefix) else s + else: + return s.removeprefix(prefix) + + def test_page_info(): """Test creation of page_info""" mets = ET.parse(TESTS_DATA_DIR / "mets-mods" / "PPN821507109-1361-pages.xml") @@ -25,5 +33,5 @@ def test_page_info(): # This is a title page with an illustration, check that we correctly got this info from the # structMap. - struct_types = sorted(k.removeprefix("structMap-LOGICAL_TYPE_") for k, v in page_info_page.items() if k.startswith("structMap-LOGICAL_TYPE_") and v == 1) + struct_types = sorted(removeprefix(k, "structMap-LOGICAL_TYPE_") for k, v in page_info_page.items() if k.startswith("structMap-LOGICAL_TYPE_") and v == 1) assert struct_types == ["illustration", "monograph", "title_page"]