tests/testthat/test_check_packages_installed.R

test_that("check_packages_installed", {
  expect_equal(check_packages_installed("mlr3misc"), setNames(TRUE, "mlr3misc"))
  expect_warning(check_packages_installed("this_is_not_a_package999"), "required but not installed")
  expect_warning(check_packages_installed("this_is_not_a_package999", msg = "foobar %s"), "foobar")
  expect_logical(check_packages_installed("this_is_not_a_package999", warn = FALSE))

  expect_true(tryCatch(check_packages_installed("this_is_not_a_package999"),
    packageNotFoundWarning = function(e) TRUE))
})

Try the mlr3misc package in your browser

Any scripts or data that you put into this service are public.

mlr3misc documentation built on Sept. 20, 2023, 5:06 p.m.