from pathlib import Path


def test_unpaginate_noparam_testfile_generation() -> None:
    test_path = Path(__file__).parent

    data_paren = (test_path / "test_unpaginate_noparam_paren.py").read_text()
    data_noparen = (test_path / "test_unpaginate_noparam_noparen.py").read_text()

    data_noparen_expected = (
        "#\n"
        "# DO NOT MODIFY THIS FILE\n"
        "#\n"
        "# This file is automatically generated when tests are run\n"
        "#\n\n"
    ) + data_paren.replace("@unpaginate()", "@unpaginate")

    needs_to_be_changed = data_noparen != data_noparen_expected

    if needs_to_be_changed:
        (test_path / "test_unpaginate_noparam_noparen.py").write_text(
            data_noparen_expected
        )
        raise RuntimeError(
            "The test files have changed and have been updated accordingly. "
            "Please re-run the tests."
        )
