Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self):

self.organisation_schema - v2.03 IATI Organisation schema.
"""
self.activity_schema = etree.XMLSchema(etree.parse('iati-activities-schema.xsd'))
self.activity_schema = etree.XMLSchema(etree.parse('iati-activities-schema.xsd'))

self.organisation_schema = etree.XMLSchema(etree.parse('iati-organisations-schema.xsd'))

Expand Down Expand Up @@ -85,15 +85,14 @@ def is_xml(xml_string):


def is_iati_xml(xml_string, schema):
parser = etree.XMLParser(schema = schema)
parser = etree.XMLParser(schema=schema)
try:
dataset = etree.fromstring(xml_string, parser)
etree.fromstring(xml_string, parser)
return True
except etree.XMLSyntaxError:
return False



@pytest.mark.parametrize('filepath', list_xml_files_recursively('tests/activity-tests/should-pass/') + # Legacy activity test cases
list_xml_files_recursively('tests/should-pass/iati-activities/') + # Activity test cases in 2.03+ format
list_xml_files_recursively('tests/organisation-tests/should-pass/') + # Legacy organisaion test cases
Expand Down Expand Up @@ -144,9 +143,9 @@ def test_2_03_fail_files(schema_factory, filepath):

assert is_xml(data_str)

parser = etree.XMLParser(schema = schema)
parser = etree.XMLParser(schema=schema)
try:
dataset = etree.fromstring(data_str, parser)
etree.fromstring(data_str, parser)
except etree.XMLSyntaxError as error_log:
expected_error_text = failure_reason_mapping[failure_reason]
if re.search(expected_error_text, str(error_log)) is None:
Expand Down
Loading