# Path: pre_commit_hooks/check_json.py
# def main(argv: Sequence[str] | None = None) -> int:
#     parser = argparse.ArgumentParser()
#     parser.add_argument('filenames', nargs='*', help='Filenames to check.')
#     args = parser.parse_args(argv)
# 
#     retval = 0
#     for filename in args.filenames:
#         with open(filename, 'rb') as f:
#             try:
#                 json.load(f, object_pairs_hook=raise_duplicate_keys)
#             except ValueError as exc:
#                 print(f'{filename}: Failed to json decode ({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_json import main
from testing.util import get_resource_path
from __future__ import annotations




@pytest.mark.parametrize(
    ('filename', 'expected_retval'), (
        ('bad_json.notjson', 1),
        ('bad_json_latin1.nonjson', 1),
        ('ok_json.json', 0),
        ('duplicate_key_json.notjson', 1),
    ),
)
def test_main(capsys, filename, expected_retval):

# Path: pre_commit_hooks/check_json.py
# def main(argv: Sequence[str] | None = None) -> int:
#     parser = argparse.ArgumentParser()
#     parser.add_argument('filenames', nargs='*', help='Filenames to check.')
#     args = parser.parse_args(argv)
# 
#     retval = 0
#     for filename in args.filenames:
#         with open(filename, 'rb') as f:
#             try:
#                 json.load(f, object_pairs_hook=raise_duplicate_keys)
#             except ValueError as exc:
#                 print(f'{filename}: Failed to json decode ({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_json_test.py
import pytest
from pre_commit_hooks.check_json import main
from testing.util import get_resource_path

from __future__ import annotations




@pytest.mark.parametrize(
    ('filename', 'expected_retval'), (
        ('bad_json.notjson', 1),
        ('bad_json_latin1.nonjson', 1),
        ('ok_json.json', 0),
        ('duplicate_key_json.notjson', 1),
    ),
)
def test_main(capsys, filename, expected_retval):

    ret = main([get_resource_path(filename)])