From e73e909b2e213ed414ab8bde155bf855a6ec6a58 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 18 Jul 2023 17:07:25 -0700 Subject: [PATCH] Optionally skip tests requiring 'MASS' --- tests/testthat/test0_simple_mm.R | 2 ++ tests/testthat/test1_glmnet.R | 2 ++ tests/testthat/test2_cv_glmnet.R | 1 + tests/testthat/test6_relaxed_cv.R | 2 ++ tests/testthat/test7_family.R | 3 +++ 5 files changed, 10 insertions(+) diff --git a/tests/testthat/test0_simple_mm.R b/tests/testthat/test0_simple_mm.R index 87c5280..deb604f 100644 --- a/tests/testthat/test0_simple_mm.R +++ b/tests/testthat/test0_simple_mm.R @@ -43,6 +43,7 @@ test_that("optional arguments work", test_that("factor handling works", { + skip_if_not_installed("MASS") data(Insurance, package="MASS") # don't worry about ordered factors for now class(Insurance$Group) <- "factor" @@ -97,6 +98,7 @@ test_that("nonsyntactic vars work", test_that("interaction/expression terms work", { + skip_if_not_installed("MASS") data(Insurance, package="MASS") xy1 <- simple_mf(Claims / Holders ~ District * Group + Age, data=Insurance) expect_is(xy1$x, "matrix") diff --git a/tests/testthat/test1_glmnet.R b/tests/testthat/test1_glmnet.R index 9fe0acc..bf49950 100644 --- a/tests/testthat/test1_glmnet.R +++ b/tests/testthat/test1_glmnet.R @@ -30,6 +30,7 @@ test_that("glmnet arguments work", { expect_equivalent(mod00$beta, mod0$beta) expect_equivalent(mod0$beta, mod1$beta) + skip_if_not_installed("MASS") data(Insurance, package="MASS") # don't worry about ordered factors for now class(Insurance$Group) <- "factor" @@ -82,6 +83,7 @@ test_that("predict and coef work", { test_that("prediction with NA works", { + skip_if_not_installed("MASS") data(Boston, package="MASS") BostonNA <- Boston BostonNA[1, ] <- NA diff --git a/tests/testthat/test2_cv_glmnet.R b/tests/testthat/test2_cv_glmnet.R index c44f6f4..a43d42f 100644 --- a/tests/testthat/test2_cv_glmnet.R +++ b/tests/testthat/test2_cv_glmnet.R @@ -1,5 +1,6 @@ context("cv.glmnet") +skip_if_not_installed("MASS") data(Boston, package="MASS") x <- as.matrix(Boston[-1]) y <- Boston$crim diff --git a/tests/testthat/test6_relaxed_cv.R b/tests/testthat/test6_relaxed_cv.R index 5c6b9cd..8d108f6 100644 --- a/tests/testthat/test6_relaxed_cv.R +++ b/tests/testthat/test6_relaxed_cv.R @@ -1,5 +1,7 @@ context("relaxed cv.glmnet") + +skip_if_not_installed("MASS") data(Boston, package="MASS") x <- as.matrix(Boston[-1]) y <- Boston$crim diff --git a/tests/testthat/test7_family.R b/tests/testthat/test7_family.R index 41aac9b..5302c5b 100644 --- a/tests/testthat/test7_family.R +++ b/tests/testthat/test7_family.R @@ -27,6 +27,7 @@ test_that("enhanced family arg works with glmnet", { test_that("enhanced family arg works with cv.glmnet", { + skip_if_not_installed("MASS") data(Boston, package="MASS") x <- as.matrix(Boston[-1]) y <- Boston$crim @@ -57,6 +58,7 @@ test_that("enhanced family arg works with cv.glmnet", { test_that("enhanced family arg works with cva.glmnet", { + skip_if_not_installed("MASS") data(Boston, package="MASS") set.seed(12345) @@ -94,6 +96,7 @@ test_that("enhanced family arg works with relaxed glmnet", { test_that("enhanced family arg works with relaxed cv.glmnet", { + skip_if_not_installed("MASS") data(Boston, package="MASS") x <- as.matrix(Boston[-1]) y <- Boston$crim