Skip to content

Commit 877550f

Browse files
committed
Add tests for full coverage of TextFeatures validation and tags
1 parent a4ab4ad commit 877550f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_text/test_text_features.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,26 @@ def test_lowercase_count(self):
242242
X_tr = transformer.fit_transform(X)
243243

244244
assert X_tr["text_lowercase_count"].tolist() == [4, 0]
245+
246+
def test_variables_list_non_strings_raises_error(self):
247+
"""Test that a list of non-string variables raises ValueError."""
248+
with pytest.raises(ValueError, match="variables must be"):
249+
TextFeatures(variables=[1, 2])
250+
251+
def test_features_list_non_strings_raises_error(self):
252+
"""Test that a list of non-string features raises ValueError."""
253+
with pytest.raises(ValueError, match="features must be"):
254+
TextFeatures(features=[1, 2])
255+
256+
def test_more_tags(self):
257+
"""Test _more_tags returns expected tags."""
258+
transformer = TextFeatures()
259+
tags = transformer._more_tags()
260+
assert tags["allow_nan"] is True
261+
assert tags["variables"] == "categorical"
262+
263+
def test_sklearn_tags(self):
264+
"""Test __sklearn_tags__ returns expected tags."""
265+
transformer = TextFeatures()
266+
tags = transformer.__sklearn_tags__()
267+
assert tags.input_tags.allow_nan is True

0 commit comments

Comments
 (0)