Skip to content

Commit 6c0b2f9

Browse files
committed
test: fix test_AcqFunctionMulti, robustify helper and loading
1 parent 917ff4e commit 6c0b2f9

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

tests/testthat.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
if (requireNamespace("testthat", quietly = TRUE)) {
22
library(testthat)
3+
library(checkmate)
34
library(mlr3mbo)
45
test_check("mlr3mbo")
56
}

tests/testthat/helper.R

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
lapply(list.files(system.file("testthat", package = "mlr3"),
2-
pattern = "^helper.*\\.[rR]", full.names = TRUE), source)
1+
library(mlr3)
2+
library(checkmate)
3+
library(testthat)
4+
5+
lapply(list.files(system.file("testthat", package = "mlr3"), pattern = "^helper.*\\.[rR]", full.names = TRUE), source)
36

47
# Simple 1D Functions
58
PS_1D = ps(
@@ -171,6 +174,15 @@ LearnerRegrError = R6::R6Class("LearnerRegrError",
171174
)
172175
)
173176

177+
expect_man_exists = function(man) {
178+
checkmate::expect_string(man, na.ok = TRUE, fixed = "::")
179+
if (!is.na(man)) {
180+
parts = strsplit(man, "::", fixed = TRUE)[[1L]]
181+
matches = help.search(parts[2L], package = parts[1L], ignore.case = FALSE)
182+
checkmate::expect_data_frame(matches$matches, min.rows = 1L, info = "man page lookup")
183+
}
184+
}
185+
174186
expect_dictionary_loop_function = function(d, contains = NA_character_, min_items = 0L) {
175187
expect_r6(d, "Dictionary")
176188
testthat::expect_output(print(d), "Dictionary")

tests/testthat/test_AcqFunctionMulti.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test_that("AcqFunctionMulti API works", {
7070
expect_true(acqf$requires_predict_type_se)
7171
expect_equal(acqf$packages, NULL)
7272
expect_true(grepl("Multi Acquisition Function of", x = acqf$label))
73-
expect_true(grepl("mlr_acqfunctions_multi", x = acqf$man, "man"))
73+
expect_true(grepl("mlr_acqfunctions_multi", x = acqf$man))
7474
})
7575

7676
test_that("AcqFunctionMulti lazy initialization", {

0 commit comments

Comments
 (0)