def test_profiles(
        self,
        project_dir_cli_arg,
        working_directory,
        write_profiles_yml,
        dbt_profile_data,
        profiles_home_root,
        profiles_project_root,
        profiles_flag_root,
        profiles_env_root,
        request,
    ):
        """Verify priority order to search for profiles.yml configuration.

        Reverse priority order:
        1. HOME directory
        2. DBT_PROFILES_DIR environment variable
        3. --profiles-dir command-line argument

        Specification later in this list will take priority over earlier ones, even when both are provided.
        """

        # https://pypi.org/project/pytest-lazy-fixture/ is an alternative to using request.getfixturevalue
        if project_dir_cli_arg is not None:
            project_dir_cli_arg = request.getfixturevalue(project_dir_cli_arg)

        if working_directory is not None:
            working_directory = request.getfixturevalue(working_directory)

        # start in the specified directory
        if working_directory is not None:
            os.chdir(working_directory)
        # default case with profiles.yml in the HOME directory
        _, stdout = self.dbt_debug(project_dir_cli_arg)
        assert f"Using profiles.yml file at {profiles_home_root}" in stdout

        # set DBT_PROFILES_DIR environment variable for the remainder of the cases
        env_vars = {"DBT_PROFILES_DIR": profiles_env_root}
        with environ(env_vars):
            _, stdout = self.dbt_debug(project_dir_cli_arg)
            assert f"Using profiles.yml file at {profiles_env_root}" in stdout

            # This additional case is also within the context manager because we want to verify
            # that it takes priority even when the relevant environment variable is also set

            # set --profiles-dir on the command-line
            _, stdout = self.dbt_debug(
                project_dir_cli_arg, profiles_dir_cli_arg=profiles_flag_root
            )
            assert f"Using profiles.yml file at {profiles_flag_root}" in stdout
Verify priority order to search for profiles.yml configuration.

        Reverse priority order:
        1. HOME directory
        2. DBT_PROFILES_DIR environment variable
        3. --profiles-dir command-line argument

        Specification later in this list will take priority over earlier ones, even when both are provided.
        
tests/functional/profiles/test_profile_dir.py