# Path: pre_commit_hooks/check_xml.py
# def main(argv: Sequence[str] | None = None) -> int:
#     parser = argparse.ArgumentParser()
#     parser.add_argument('filenames', nargs='*', help='XML filenames to check.')
#     args = parser.parse_args(argv)
# 
#     retval = 0
#     handler = xml.sax.handler.ContentHandler()
#     for filename in args.filenames:
#         try:
#             with open(filename, 'rb') as xml_file:
#                 xml.sax.parse(xml_file, handler)
#         except xml.sax.SAXException as exc:
#             print(f'{filename}: Failed to xml parse ({exc})')
#             retval = 1
#     return retval
# 
# Path: testing/util.py
# def get_resource_path(path):
#     return os.path.join(TESTING_DIR, 'resources', path)


import pytest
from pre_commit_hooks.check_xml import main
from testing.util import get_resource_path
from __future__ import annotations




@pytest.mark.parametrize(
    ('filename', 'expected_retval'), (
        ('bad_xml.notxml', 1),
        ('ok_xml.xml', 0),
    ),
)
def test_main(filename, expected_retval):

# Path: pre_commit_hooks/check_xml.py
# def main(argv: Sequence[str] | None = None) -> int:
#     parser = argparse.ArgumentParser()
#     parser.add_argument('filenames', nargs='*', help='XML filenames to check.')
#     args = parser.parse_args(argv)
# 
#     retval = 0
#     handler = xml.sax.handler.ContentHandler()
#     for filename in args.filenames:
#         try:
#             with open(filename, 'rb') as xml_file:
#                 xml.sax.parse(xml_file, handler)
#         except xml.sax.SAXException as exc:
#             print(f'{filename}: Failed to xml parse ({exc})')
#             retval = 1
#     return retval
# 
# Path: testing/util.py
# def get_resource_path(path):
#     return os.path.join(TESTING_DIR, 'resources', path)


# Path: tests/check_xml_test.py
import pytest
from pre_commit_hooks.check_xml import main
from testing.util import get_resource_path

from __future__ import annotations




@pytest.mark.parametrize(
    ('filename', 'expected_retval'), (
        ('bad_xml.notxml', 1),
        ('ok_xml.xml', 0),
    ),
)
def test_main(filename, expected_retval):

    ret = main([get_resource_path(filename)])