code: def test_attrs_raise_if_not_fitted(
      automl: AutoML,
      attr: str,
      argnames: Union[List[str], None],
  ) -> None:
      """
      Parameters
      ----------
      automl : AutoML
          An unfitted automl instance
  
      attr: str
          The attribute to test
  
      argnames: Union[List[str], None]
          The arguments of the the method
          * ["arg1", "arg2"] for method with args
          * [] for method with no args
          * None for property
  
      Expects
      -------
      * Should raise a NotFittedError
  
      Note
      ----
      * This also ensures any validation should be done after the fit check as
      NotFittedError should be raised
      """
      with pytest.raises(NotFittedError):
          if argnames is None:
              property = getattr(automl, attr)  # noqa
          else:
              method = getattr(automl, attr)
              args = {name: None for name in argnames}
              if len(args) > 0:
                  method(args)
              else:
                  method()
  
file_path: auto-sklearn/test/test_automl/test_sklearn_compliance.py
imports: from typing import List, Union
  from sklearn.exceptions import NotFittedError
  from autosklearn.automl import AutoML
  import pytest
  from pytest_cases import parametrize, parametrize_with_cases
  from pytest_cases.filters import has_tag
  import test.test_automl.cases
label_desc: Use image node_id 1 for calling a global function with example usage: test_attrs_raise_if_not_fitted(automl, attr, argnames) without return types