def METHOD_NAME(
    command: str,
    poetry: Poetry | None = None,
    installer: Installer | None = None,
    executor: Executor | None = None,
    environment: Env | None = None,
) -> CommandTester:
    command_obj = app.find(command)
    tester = CommandTester(command_obj)
    # Setting the formatter from the application
    # TODO: Find a better way to do this in Cleo
    app_io = app.create_io()
    formatter = app_io.output.formatter
    tester.io.output.set_formatter(formatter)
    tester.io.error_output.set_formatter(formatter)
    if poetry:
        app._poetry = poetry
    poetry = app.poetry
    if hasattr(command_obj, "set_env"):
        command_obj.set_env(environment or env)
    if hasattr(command_obj, "set_installer"):
        installer = installer or Installer(
            tester.io,
            env,
            poetry.package,
            poetry.locker,
            poetry.pool,
            poetry.config,
            executor=executor
            or TestExecutor(env, poetry.pool, poetry.config, tester.io),
        )
        command_obj.set_installer(installer)
    return tester