# Path: pre_commit_hooks/string_fixer.py
# def main(argv: Sequence[str] | None = None) -> int:
#     parser = argparse.ArgumentParser()
#     parser.add_argument('filenames', nargs='*', help='Filenames to fix')
#     args = parser.parse_args(argv)
# 
#     retv = 0
# 
#     for filename in args.filenames:
#         return_value = fix_strings(filename)
#         if return_value != 0:
#             print(f'Fixing strings in {filename}')
#         retv |= return_value
# 
#     return retv


import textwrap
import pytest
from pre_commit_hooks.string_fixer import main
    ('x = "foo"', "x = 'foo'", 1),
    # Test escaped characters
    (r'"\'"', r'"\'"', 0),
    # Docstring
    ('""" Foo """', '""" Foo """', 0),
    (
        textwrap.dedent(
            """
        x = " \\
        foo \\
        "\n
        """,
        ),
        textwrap.dedent(
            """
        x = ' \\
        foo \\
        '\n
        """,
        ),
        1,
    ),
    ('"foo""bar"', "'foo''bar'", 1),
)


@pytest.mark.parametrize(('input_s', 'output', 'expected_retval'), TESTS)
def test_rewrite(input_s, output, expected_retval, tmpdir):
    path = tmpdir.join('file.py')
    path.write(input_s)

# Path: pre_commit_hooks/string_fixer.py
# def main(argv: Sequence[str] | None = None) -> int:
#     parser = argparse.ArgumentParser()
#     parser.add_argument('filenames', nargs='*', help='Filenames to fix')
#     args = parser.parse_args(argv)
# 
#     retv = 0
# 
#     for filename in args.filenames:
#         return_value = fix_strings(filename)
#         if return_value != 0:
#             print(f'Fixing strings in {filename}')
#         retv |= return_value
# 
#     return retv


# Path: tests/string_fixer_test.py
import textwrap
import pytest
from pre_commit_hooks.string_fixer import main

    ('x = "foo"', "x = 'foo'", 1),
    # Test escaped characters
    (r'"\'"', r'"\'"', 0),
    # Docstring
    ('""" Foo """', '""" Foo """', 0),
    (
        textwrap.dedent(
            """
        x = " \\
        foo \\
        "\n
        """,
        ),
        textwrap.dedent(
            """
        x = ' \\
        foo \\
        '\n
        """,
        ),
        1,
    ),
    ('"foo""bar"', "'foo''bar'", 1),
)


@pytest.mark.parametrize(('input_s', 'output', 'expected_retval'), TESTS)
def test_rewrite(input_s, output, expected_retval, tmpdir):
    path = tmpdir.join('file.py')
    path.write(input_s)

    retval = main([str(path)])