def METHOD_NAME(request):
    def _write_profiles_yml(profiles_dir, dbt_profile_contents):
        def cleanup():
            rm_file(Path(profiles_dir) / "profiles.yml")
        request.addfinalizer(cleanup)
        write_file(yaml.safe_dump(dbt_profile_contents), profiles_dir, "profiles.yml")
    return _write_profiles_yml