def wrap_plan(*lines: str) -> str:
    """ Wrap in pgtap plan functions, assumes each line is a test """
    # You can't run a pgTap query without a plan unless it's a
    # runtests() call to db test functions

    return "\n".join(
        [
            "BEGIN;",
            "SELECT plan(%s);" % len(lines),
            *lines,
            "SELECT * FROM finish();",
            "ROLLBACK;",
        ]
    )