def test_validate_sql_failure(
        self,
        adapter: BaseAdapter,
        invalid_sql: str,
        expected_exception: Type[Exception],
    ) -> None:
        """Executes validate_sql on invalid SQL, expecting the exception."""
        with pytest.raises(expected_exception=expected_exception) as excinfo:
            with adapter.connection_named("test_invalid_sql_validation"):
                adapter.validate_sql(invalid_sql)

        # InvalidConnectionError is a subclass of DbtRuntimeError, so we have to handle
        # it separately.
        if excinfo.type == InvalidConnectionError:
            raise ValueError(
                "Unexpected InvalidConnectionError. This typically indicates a problem "
                "with the test setup, rather than the expected error for an invalid "
                "validate_sql query."
            ) from excinfo.value
Executes validate_sql on invalid SQL, expecting the exception.
tests/functional/adapter/utils/test_validate_sql.py