Skip to content

Commit 7132631

Browse files
authored
hot fix (test match) (#1852)
* fix * fix * fix * fix * fix * fix * fix
1 parent eaabc67 commit 7132631

File tree

7 files changed

+82
-23
lines changed

7 files changed

+82
-23
lines changed

tests/clv/models/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def test_validate_cols_reports_all_missing_columns(self):
284284
"frequency": [1, 2, 3],
285285
}
286286
)
287-
expected_error_msg = "The following required columns are missing from the input data: ['T', 'recency']"
287+
expected_error_msg = r"The following required columns are missing from the input data: \['T', 'recency'\]"
288288

289289
with pytest.raises(ValueError, match=expected_error_msg):
290290
CLVModel._validate_cols(data=data, required_cols=required)

tests/clv/models/test_beta_geo.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,34 @@ def test_model(self, model_config, default_model_config):
142142
def test_missing_cols(self):
143143
data_invalid = self.data.drop(columns="customer_id")
144144

145-
with pytest.raises(ValueError, match="Required column customer_id missing"):
145+
with pytest.raises(
146+
ValueError,
147+
match=r"The following required columns are missing from the input data: \['customer_id'\]",
148+
):
146149
BetaGeoModel(data=data_invalid)
147150

148151
data_invalid = self.data.drop(columns="frequency")
149152

150-
with pytest.raises(ValueError, match="Required column frequency missing"):
153+
with pytest.raises(
154+
ValueError,
155+
match=r"The following required columns are missing from the input data: \['frequency'\]",
156+
):
151157
BetaGeoModel(data=data_invalid)
152158

153159
data_invalid = self.data.drop(columns="recency")
154160

155-
with pytest.raises(ValueError, match="Required column recency missing"):
161+
with pytest.raises(
162+
ValueError,
163+
match=r"The following required columns are missing from the input data: \['recency'\]",
164+
):
156165
BetaGeoModel(data=data_invalid)
157166

158167
data_invalid = self.data.drop(columns="T")
159168

160-
with pytest.raises(ValueError, match="Required column T missing"):
169+
with pytest.raises(
170+
ValueError,
171+
match=r"The following required columns are missing from the input data: \['T'\]",
172+
):
161173
BetaGeoModel(data=data_invalid)
162174

163175
def test_customer_id_duplicate(self):

tests/clv/models/test_beta_geo_beta_binom.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,34 @@ def test_model(self, model_config):
176176
def test_missing_cols(self):
177177
data_invalid = self.data.drop(columns="customer_id")
178178

179-
with pytest.raises(ValueError, match="Required column customer_id missing"):
179+
with pytest.raises(
180+
ValueError,
181+
match=r"The following required columns are missing from the input data: \['customer_id'\]",
182+
):
180183
BetaGeoBetaBinomModel(data=data_invalid)
181184

182185
data_invalid = self.data.drop(columns="frequency")
183186

184-
with pytest.raises(ValueError, match="Required column frequency missing"):
187+
with pytest.raises(
188+
ValueError,
189+
match=r"The following required columns are missing from the input data: \['frequency'\]",
190+
):
185191
BetaGeoBetaBinomModel(data=data_invalid)
186192

187193
data_invalid = self.data.drop(columns="recency")
188194

189-
with pytest.raises(ValueError, match="Required column recency missing"):
195+
with pytest.raises(
196+
ValueError,
197+
match=r"The following required columns are missing from the input data: \['recency'\]",
198+
):
190199
BetaGeoBetaBinomModel(data=data_invalid)
191200

192201
data_invalid = self.data.drop(columns="T")
193202

194-
with pytest.raises(ValueError, match="Required column T missing"):
203+
with pytest.raises(
204+
ValueError,
205+
match=r"The following required columns are missing from the input data: \['T'\]",
206+
):
195207
BetaGeoBetaBinomModel(data=data_invalid)
196208

197209
def test_customer_id_duplicate(self):
@@ -212,7 +224,7 @@ def test_customer_id_duplicate(self):
212224
)
213225

214226
def test_T_homogeneity(self):
215-
with pytest.raises(ValueError, match="Column T has non-homogeneous entries"):
227+
with pytest.raises(ValueError, match="Column T has non-homogeneous entries"):
216228
data = pd.DataFrame(
217229
{
218230
"customer_id": np.asarray([1, 2]),

tests/clv/models/test_gamma_gamma.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,26 @@ def setup_class(cls):
8282
class TestGammaGammaModel(BaseTestGammaGammaModel):
8383
def test_missing_columns(self):
8484
data_invalid = self.data.drop(columns="customer_id")
85-
with pytest.raises(ValueError, match="Required column customer_id missing"):
85+
with pytest.raises(
86+
ValueError,
87+
match=r"The following required columns are missing from the input data: \['customer_id'\]",
88+
):
8689
GammaGammaModel(data=data_invalid)
8790

8891
data_invalid = self.data.drop(columns="frequency")
8992

90-
with pytest.raises(ValueError, match="Required column frequency missing"):
93+
with pytest.raises(
94+
ValueError,
95+
match=r"The following required columns are missing from the input data: \['frequency'\]",
96+
):
9197
GammaGammaModel(data=data_invalid)
9298

9399
data_invalid = self.data.drop(columns="monetary_value")
94100

95-
with pytest.raises(ValueError, match="Required column monetary_value missing"):
101+
with pytest.raises(
102+
ValueError,
103+
match=r"The following required columns are missing from the input data: \['monetary_value'\]",
104+
):
96105
GammaGammaModel(data=data_invalid)
97106

98107
@pytest.mark.parametrize(
@@ -311,13 +320,17 @@ class TestGammaGammaModelIndividual(BaseTestGammaGammaModel):
311320
def test_missing_columns(self):
312321
# Create a version of the data that's missing the 'customer_id' column
313322
data_invalid = self.individual_data.drop(columns="customer_id")
314-
with pytest.raises(ValueError, match="Required column customer_id missing"):
323+
with pytest.raises(
324+
ValueError,
325+
match=r"The following required columns are missing from the input data: \['customer_id'\]",
326+
):
315327
GammaGammaModelIndividual(data=data_invalid)
316328

317329
data_invalid = self.individual_data.drop(columns="individual_transaction_value")
318330

319331
with pytest.raises(
320-
ValueError, match="Required column individual_transaction_value missing"
332+
ValueError,
333+
match=r"The following required columns are missing from the input data: \['individual_transaction_value'\]",
321334
):
322335
GammaGammaModelIndividual(data=data_invalid)
323336

tests/clv/models/test_modified_beta_geo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def test_missing_cols(self, missing_column):
145145
data_invalid = self.data.drop(columns=missing_column)
146146

147147
with pytest.raises(
148-
ValueError, match=f"Required column {missing_column} missing"
148+
ValueError,
149+
match=rf"The following required columns are missing from the input data: \['{missing_column}'\]",
149150
):
150151
ModifiedBetaGeoModel(data=data_invalid)
151152

tests/clv/models/test_pareto_nbd.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,34 @@ def test_model(self, model_config, default_model_config):
153153
def test_missing_cols(self):
154154
data_invalid = self.data.drop(columns="customer_id")
155155

156-
with pytest.raises(ValueError, match="Required column customer_id missing"):
156+
with pytest.raises(
157+
ValueError,
158+
match=r"The following required columns are missing from the input data: \['customer_id'\]",
159+
):
157160
ParetoNBDModel(data=data_invalid)
158161

159162
data_invalid = self.data.drop(columns="frequency")
160163

161-
with pytest.raises(ValueError, match="Required column frequency missing"):
164+
with pytest.raises(
165+
ValueError,
166+
match=r"The following required columns are missing from the input data: \['frequency'\]",
167+
):
162168
ParetoNBDModel(data=data_invalid)
163169

164170
data_invalid = self.data.drop(columns="recency")
165171

166-
with pytest.raises(ValueError, match="Required column recency missing"):
172+
with pytest.raises(
173+
ValueError,
174+
match=r"The following required columns are missing from the input data: \['recency'\]",
175+
):
167176
ParetoNBDModel(data=data_invalid)
168177

169178
data_invalid = self.data.drop(columns="T")
170179

171-
with pytest.raises(ValueError, match="Required column T missing"):
180+
with pytest.raises(
181+
ValueError,
182+
match=r"The following required columns are missing from the input data: \['T'\]",
183+
):
172184
ParetoNBDModel(data=data_invalid)
173185

174186
def test_customer_id_error(self):

tests/clv/models/test_shifted_beta_geo.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,26 @@ def test_missing_cols(self, data):
8383
# Create a version of the data that's missing the 'customer_id' column
8484
data_invalid = data.drop(columns="customer_id")
8585

86-
with pytest.raises(ValueError, match="Required column customer_id missing"):
86+
with pytest.raises(
87+
ValueError,
88+
match=r"The following required columns are missing from the input data: \['customer_id'\]",
89+
):
8790
ShiftedBetaGeoModelIndividual(data=data_invalid)
8891

8992
data_invalid = data.drop(columns="t_churn")
9093

91-
with pytest.raises(ValueError, match="Required column t_churn missing"):
94+
with pytest.raises(
95+
ValueError,
96+
match=r"The following required columns are missing from the input data: \['t_churn'\]",
97+
):
9298
ShiftedBetaGeoModelIndividual(data=data_invalid)
9399

94100
data_invalid = data.drop(columns="T")
95101

96-
with pytest.raises(ValueError, match="Required column T missing"):
102+
with pytest.raises(
103+
ValueError,
104+
match=r"The following required columns are missing from the input data: \['T'\]",
105+
):
97106
ShiftedBetaGeoModelIndividual(data=data_invalid)
98107

99108
def test_model_repr(self, default_model_config):

0 commit comments

Comments
 (0)