code: def test_find_or_check_categorical_variables(
      df_vartypes, df_datetime, df_numeric_columns
  ):
      vars_cat = ["Name", "City"]
      vars_mix = ["Age", "Marks", "Name"]
  
      # errors when vars entered by user are not categorical
      with pytest.raises(TypeError):
          assert _find_or_check_categorical_variables(
              df_vartypes, "Marks"
          )
      with pytest.raises(TypeError):
          assert _find_or_check_categorical_variables(
              df_datetime, "datetime_range"
          )
      with pytest.raises(TypeError):
          assert _find_or_check_categorical_variables(
              df_datetime, ["datetime_range"]
          )
      with pytest.raises(TypeError):
          assert _find_or_check_categorical_variables(
              df_numeric_columns, 3
          )
      with pytest.raises(TypeError):
          assert _find_or_check_categorical_variables(
              df_numeric_columns, [0, 2]
          )
      with pytest.raises(TypeError):
          assert _find_or_check_categorical_variables(
              df_vartypes, vars_mix
          )
  
      # error when user enters empty list
      with pytest.raises(ValueError):
          assert _find_or_check_categorical_variables(
              df_vartypes, variables=[]
          )
  
      # error when df has no categorical variables
      with pytest.raises(ValueError):
          assert _find_or_check_categorical_variables(
              df_vartypes[["Age", "Marks"]], None
          )
      with pytest.raises(ValueError):
          assert _find_or_check_categorical_variables(
              df_datetime[["date_obj1", "time_obj"]], None
          )
  
      # when variables=None
      assert (
          _find_or_check_categorical_variables(df_vartypes, None)
          == vars_cat
      )
      assert _find_or_check_categorical_variables(
          df_datetime, None
      ) == ["Name"]
  
      # when vars are specified
      assert _find_or_check_categorical_variables(
          df_vartypes, "Name"
      ) == ["Name"]
      assert _find_or_check_categorical_variables(
          df_datetime, "date_obj1"
      ) == ["date_obj1"]
      assert (
          _find_or_check_categorical_variables(df_vartypes, vars_cat)
          == vars_cat
      )
      assert _find_or_check_categorical_variables(
          df_datetime, ["Name", "date_obj1"]
      ) == [
          "Name",
          "date_obj1",
      ]
  
      # vars specified, column name is integer
      assert _find_or_check_categorical_variables(
          df_numeric_columns, [0, 1]
      ) == [0, 1]
      assert _find_or_check_categorical_variables(
          df_numeric_columns, 0
      ) == [0]
      assert _find_or_check_categorical_variables(
          df_numeric_columns, 1
      ) == [1]
  
      # datetime vars cast as category
      # object-like datetime
      df_datetime["date_obj1"] = df_datetime["date_obj1"].astype(
          "category"
      )
      assert _find_or_check_categorical_variables(
          df_datetime, None
      ) == ["Name"]
      assert _find_or_check_categorical_variables(
          df_datetime, ["Name", "date_obj1"]
      ) == [
          "Name",
          "date_obj1",
      ]
      # datetime64
      df_datetime["datetime_range"] = df_datetime[
          "datetime_range"
      ].astype("category")
      assert _find_or_check_categorical_variables(
          df_datetime, None
      ) == ["Name"]
      assert _find_or_check_categorical_variables(
          df_datetime, ["Name", "datetime_range"]
      ) == ["Name", "datetime_range"]
  
      # time-aware datetime var
      tz_time = pd.DataFrame(
          {
              "time_objTZ": df_datetime["time_obj"].add(
                  ["+5", "+11", "-3", "-8"]
              )
          }
      )
      with pytest.raises(ValueError):
          assert _find_or_check_categorical_variables(tz_time, None)
      assert _find_or_check_categorical_variables(
          tz_time, "time_objTZ"
      ) == ["time_objTZ"]
  
file_path: feature_engine/tests/test_variable_handling/test_variable_type_selection.py
imports: import pandas
  import pytest
  from feature_engine._variable_handling.variable_type_selection import _filter_out_variables_not_in_dataframe, _find_all_variables, _find_categorical_and_numerical_variables, _find_or_check_categorical_variables, _find_or_check_datetime_variables, _find_or_check_numerical_variables
label_desc: Use image node_id 3 for calling a global function with example usage: test_find_or_check_categorical_variables(df_vartypes, df_datetime, df_numeric_columns) without return types