code: def test_raises_error_if_negative_values_after_adding_C(df_vartypes):
      user_var = "Age"
      df_neg = df_vartypes.copy()
      df_neg.loc[2, user_var] = -7
  
      with pytest.raises(ValueError) as errmsg:
          transformer = LogCpTransformer(
              base="e", variables=user_var, C=1
          )
          transformer.fit(df_neg)
  
      exceptionmsg = errmsg.value.args[0]
  
      assert (
          exceptionmsg
          == "Some variables contain zero or negative values after addingconstant C, "
          + "can't apply log"
      )
  
      # when variable contains negative value, transform
      with pytest.raises(ValueError):
          transformer = LogCpTransformer(
              base="e", variables=user_var, C=1
          )
          transformer.fit(df_vartypes)
          transformer.transform(df_neg)
  
      assert (
          exceptionmsg
          == "Some variables contain zero or negative values after addingconstant C, "
          + "can't apply log"
      )
  
file_path: feature_engine/tests/test_transformation/test_logcp_transformer.py
imports: import pandas
  import pytest
  from sklearn.exceptions import NotFittedError
  from feature_engine.transformation import LogCpTransformer
label_desc: Use image node_id 8 for calling a global function with example usage: test_raises_error_if_negative_values_after_adding_C(df_vartypes) without return types