code: def test_error_if_input_df_contains_categories_not_present_in_training_df(
      df_enc, df_enc_rare
  ):
      # test case 4: when dataset to be transformed contains categories not present
      # in training dataset
      msg = "During the encoding, NaN values were introduced in the feature(s) var_A."
  
      # check for warning when rare_labels equals 'ignore'
      with pytest.warns(UserWarning) as record:
          encoder = OrdinalEncoder(unseen="ignore")
          encoder.fit(df_enc[["var_A", "var_B"]], df_enc["target"])
          encoder.transform(df_enc_rare[["var_A", "var_B"]])
  
      # check that only one warning was raised
      assert len(record) == 1
      # check that the message matches
      assert record[0].message.args[0] == msg
  
      # check for error when rare_labels equals 'raise'
      with pytest.raises(ValueError) as record:
          encoder = OrdinalEncoder(unseen="raise")
          encoder.fit(df_enc[["var_A", "var_B"]], df_enc["target"])
          encoder.transform(df_enc_rare[["var_A", "var_B"]])
  
      # check that the error message matches
      assert str(record.value) == msg
  
file_path: feature_engine/tests/test_encoding/test_ordinal_encoder.py
imports: import numpy
  import pandas
  import pytest
  from feature_engine.encoding import OrdinalEncoder
label_desc: Use image node_id 5 for calling a global function with example usage: test_error_if_input_df_contains_categories_not_present_in_training_df(df_enc, df_enc_rare) without return types