schema_file = 'test.xsd'
with open(schema_file) as f_schema:
    schema_doc = etree.parse(f_schema)
schema = etree.XMLSchema(schema_doc)
parser = etree.XMLParser(schema=schema)
How to validate an xml file against an XSD Schema using Amara library in Python?