def METHOD_NAME(tmp_path, capsys):
    (tmp_path / "a.whl").write_text("a")
    (tmp_path / "b.tar").write_text("b")
    (tmp_path / "c.zip").write_text("c")
    bucket_name = "mybucket"
    s3_client = boto3.client("s3", region_name="us-east-1")
    s3_client.create_bucket(Bucket=bucket_name)
    deploy_to_s3_main(
        tmp_path,
        remote_prefix=PurePosixPath("dev/full/"),
        bucket=bucket_name,
        cache_control="max-age=30758400",
        pretend=False,
        overwrite=False,
        rm_remote_prefix=False,
        access_key_env="AWS_ACCESS_KEY_ID",
        secret_key_env="AWS_SECRET_ACCESS_KEY",
    )
    def get_object_list():
        response = s3_client.list_objects_v2(Bucket=bucket_name, Prefix="dev/full/")
        return set(obj["Key"] for obj in response["Contents"])
    assert get_object_list() == {"dev/full/a.whl", "dev/full/b.tar", "dev/full/c.zip"}
    # Writing a second time to the same prefix with overwrite=False should fail
    with pytest.raises(Exception):
        deploy_to_s3_main(
            tmp_path,
            remote_prefix=PurePosixPath("dev/full/"),
            bucket=bucket_name,
            cache_control="max-age=30758400",
            pretend=False,
            overwrite=False,
            rm_remote_prefix=False,
            access_key_env="AWS_ACCESS_KEY_ID",
            secret_key_env="AWS_SECRET_ACCESS_KEY",
        )
    msg = "Cannot upload .* because it already exists"
    captured = capsys.readouterr()
    # Check for error message in last two lines of output
    assert re.search(msg, "\n".join(captured.out.splitlines()[-2:]))
    # Setting overwrite=True should overwrite the files
    deploy_to_s3_main(
        tmp_path,
        remote_prefix=PurePosixPath("dev/full/"),
        bucket=bucket_name,
        cache_control="max-age=30758400",
        pretend=False,
        overwrite=True,
        rm_remote_prefix=False,
        access_key_env="AWS_ACCESS_KEY_ID",
        secret_key_env="AWS_SECRET_ACCESS_KEY",
    )
    assert get_object_list() == {"dev/full/a.whl", "dev/full/b.tar", "dev/full/c.zip"}
    # Setting rm_remote_prefix=True, should remove remote files that don't exist locally
    (tmp_path / "b.tar").unlink()
    deploy_to_s3_main(
        tmp_path,
        remote_prefix=PurePosixPath("dev/full/"),
        bucket=bucket_name,
        cache_control="max-age=30758400",
        pretend=False,
        overwrite=False,
        rm_remote_prefix=True,
        access_key_env="AWS_ACCESS_KEY_ID",
        secret_key_env="AWS_SECRET_ACCESS_KEY",
    )
    assert get_object_list() == {"dev/full/c.zip", "dev/full/a.whl"}