From 6d2b4310b9169dbd91411238ac96eafa8b8aeb1c Mon Sep 17 00:00:00 2001 From: Matthias Schmidtblaicher Date: Wed, 10 Jan 2024 16:16:18 +0100 Subject: [PATCH] catch case of unseen missings and fail method --- tests/glm/test_glm.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/glm/test_glm.py b/tests/glm/test_glm.py index a8d998b3..0bc3c68e 100644 --- a/tests/glm/test_glm.py +++ b/tests/glm/test_glm.py @@ -3186,7 +3186,7 @@ def test_cat_missing(cat_missing_method, unseen_missing): ) if cat_missing_method == "fail" and not unseen_missing: - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="Categorical data can't have missing values"): model.fit(X, y) else: model.fit(X, y) @@ -3199,4 +3199,8 @@ def test_cat_missing(cat_missing_method, unseen_missing): np.testing.assert_array_equal(model.feature_names_, feature_names) assert len(model.coef_) == len(feature_names) - model.predict(X_unseen) + if cat_missing_method == "fail" and unseen_missing: + with pytest.raises(ValueError, match="Categorical data can't have missing values"): + model.predict(X_unseen) + else: + model.predict(X_unseen)