"tests/vscode:/vscode.git/clone" did not exist on "c134d3d9c862bac9bb56a0e31e3213d020593cdd"
Unverified Commit 59f59c9f authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] [ci] silence more logs in tests (fixes #4862) (#5250)

parent fb37e507
......@@ -561,6 +561,7 @@ test_that("lgb.cv() raises an informative error for unrecognized objectives", {
, label = train$label
)
expect_error({
capture.output({
bst <- lgb.cv(
data = dtrain
, params = list(
......@@ -568,6 +569,7 @@ test_that("lgb.cv() raises an informative error for unrecognized objectives", {
, verbosity = VERBOSITY
)
)
}, type = "message")
}, regexp = "Unknown objective type name: not_a_real_objective")
})
......@@ -723,6 +725,7 @@ test_that("lgb.train() raises an informative error for unrecognized objectives",
, label = train$label
)
expect_error({
capture.output({
bst <- lgb.train(
data = dtrain
, params = list(
......@@ -730,6 +733,7 @@ test_that("lgb.train() raises an informative error for unrecognized objectives",
, verbosity = VERBOSITY
)
)
}, type = "message")
}, regexp = "Unknown objective type name: not_a_real_objective")
})
......@@ -2441,11 +2445,13 @@ test_that("lgb.train() w/ linear learner fails already-constructed dataset with
)
dtrain$construct()
expect_error({
capture.output({
bst_linear <- lgb.train(
data = dtrain
, nrounds = 10L
, params = utils::modifyList(params, list(linear_tree = TRUE))
)
}, type = "message")
}, regexp = "Cannot change linear_tree after constructed Dataset handle")
})
......
......@@ -226,7 +226,9 @@ test_that("cpp errors should be raised as proper R errors", {
, init_score = seq_len(10L)
)
expect_error({
capture.output({
dtrain$construct()
}, type = "message")
}, regexp = "Initial score size doesn't match data size")
})
......
......@@ -749,7 +749,11 @@ test_that("Saving a model with unknown importance type fails", {
UNSUPPORTED_IMPORTANCE <- 2L
expect_error({
model_string <- bst$save_model_to_string(feature_importance_type = UNSUPPORTED_IMPORTANCE)
capture.output({
model_string <- bst$save_model_to_string(
feature_importance_type = UNSUPPORTED_IMPORTANCE
)
}, type = "message")
}, "Unknown importance type")
})
......@@ -964,10 +968,12 @@ test_that("Booster$new() raises informative errors for malformed inputs", {
# unrecognized objective
expect_error({
capture.output({
Booster$new(
params = list(objective = "not_a_real_objective")
, train_set = dtrain
)
}, type = "message")
}, regexp = "Unknown objective type name: not_a_real_objective")
# train_set is not a Dataset
......@@ -986,10 +992,12 @@ test_that("Booster$new() raises informative errors for malformed inputs", {
# model file doesn't exist
expect_error({
capture.output({
Booster$new(
params = list()
, modelfile = "file-that-does-not-exist.model"
)
}, type = "message")
}, regexp = "Could not open file-that-does-not-exist.model")
# model file doesn't contain a valid LightGBM model
......@@ -999,18 +1007,22 @@ test_that("Booster$new() raises informative errors for malformed inputs", {
, con = model_file
)
expect_error({
capture.output({
Booster$new(
params = list()
, modelfile = model_file
)
}, type = "message")
}, regexp = "Unknown model format or submodel type in model file")
# malformed model string
expect_error({
capture.output({
Booster$new(
params = list()
, model_str = "a\nb\n"
)
}, type = "message")
}, regexp = "Model file doesn't specify the number of classes")
# model string isn't character or raw
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment