mirror of
				https://github.com/qurator-spk/modstool.git
				synced 2025-11-04 03:14:14 +01:00 
			
		
		
		
	✔ Fix tests on Python 3.8 by backporting removeprefix
This commit is contained in:
		
							parent
							
								
									8d0dc72ca2
								
							
						
					
					
						commit
						16a3a3bcc8
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
from pathlib import Path
 | 
					from pathlib import Path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from lxml import etree as ET
 | 
					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"
 | 
					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():
 | 
					def test_page_info():
 | 
				
			||||||
    """Test creation of page_info"""
 | 
					    """Test creation of page_info"""
 | 
				
			||||||
    mets = ET.parse(TESTS_DATA_DIR / "mets-mods" / "PPN821507109-1361-pages.xml")
 | 
					    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
 | 
					    # This is a title page with an illustration, check that we correctly got this info from the
 | 
				
			||||||
    # structMap.
 | 
					    # 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"]
 | 
					    assert struct_types == ["illustration", "monograph", "title_page"]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue