Skip to content

Commit a725360

Browse files
[python-package] Add specific error messages to some test_basic tests (#6887)
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
1 parent 06e94ad commit a725360

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tests/python_package_test/test_basic.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,22 +271,25 @@ def test_add_features_throws_if_num_data_unequal(rng):
271271
X2 = rng.uniform(size=(10, 1))
272272
d1 = lgb.Dataset(X1).construct()
273273
d2 = lgb.Dataset(X2).construct()
274-
with pytest.raises(lgb.basic.LightGBMError):
274+
with pytest.raises(
275+
lgb.basic.LightGBMError, match="Cannot add features from other Dataset with a different number of rows"
276+
):
275277
d1.add_features_from(d2)
276278

277279

278280
def test_add_features_throws_if_datasets_unconstructed(rng):
279281
X1 = rng.uniform(size=(100, 1))
280282
X2 = rng.uniform(size=(100, 1))
281-
with pytest.raises(ValueError):
283+
err_msg = "Both source and target Datasets must be constructed before adding features"
284+
with pytest.raises(ValueError, match=err_msg):
282285
d1 = lgb.Dataset(X1)
283286
d2 = lgb.Dataset(X2)
284287
d1.add_features_from(d2)
285-
with pytest.raises(ValueError):
288+
with pytest.raises(ValueError, match=err_msg):
286289
d1 = lgb.Dataset(X1).construct()
287290
d2 = lgb.Dataset(X2)
288291
d1.add_features_from(d2)
289-
with pytest.raises(ValueError):
292+
with pytest.raises(ValueError, match=err_msg):
290293
d1 = lgb.Dataset(X1)
291294
d2 = lgb.Dataset(X2).construct()
292295
d1.add_features_from(d2)

0 commit comments

Comments
 (0)