Skip to content

Commit

Permalink
skip dependent tests without modeldata / recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Oct 31, 2024
1 parent 68f3be0 commit 6ee7c0a
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/testthat/helper-sparsevctrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# For sparse tibble testing

sparse_hotel_rates <- function(tibble = FALSE) {
if (!rlang::is_installed("modeldata")) {
return()
}

# 99.2 sparsity
hotel_rates <- modeldata::hotel_rates

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-broom.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

# ------------------------------------------------------------------------------
# tidy()

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-butcher.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("attaches the butcher class", {
skip_if_not_installed("butcher")

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-extract.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
skip_if_not_installed("recipes")
skip_if_not_installed("modeldata")

data(Chicago, package = "modeldata")

# ------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-fit-action-model.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ test_that("prompt on spec without a loaded implementation (#174)", {
expect_snapshot(error = TRUE, workflow(spec = mod))
})

skip_if_not_installed("recipes")

test_that("cannot add two models", {
mod <- parsnip::linear_reg()
mod <- parsnip::set_engine(mod, "lm")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-fit.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

data("hardhat-example-data", package = "hardhat")

test_that("can `fit()` a workflow with a recipe", {
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-generics.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("can compute required packages of a workflow - formula", {
mod <- parsnip::linear_reg()
mod <- parsnip::set_engine(mod, "lm")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-post-action-tailor.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("tailor")

test_that("can add a postprocessor to a workflow", {
post <- tailor::tailor()

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-pre-action-case-weights.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

# ------------------------------------------------------------------------------
# add_case_weights()

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-pre-action-formula.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("can add a formula to a workflow", {
workflow <- workflow()
workflow <- add_formula(workflow, mpg ~ cyl)
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-pre-action-recipe.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("can add a recipe to a workflow", {
rec <- recipes::recipe(mpg ~ cyl, mtcars)

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-pre-action-variables.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("can add variables to a workflow", {
wf <- workflow()
wf <- add_variables(wf, y, c(x1, x2))
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-predict.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("can predict from a workflow", {
mod <- parsnip::linear_reg()
mod <- parsnip::set_engine(mod, "lm")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-printing.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("can print empty workflow", {
expect_snapshot(workflow())
})
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-pull.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

# ------------------------------------------------------------------------------
# pull_workflow_preprocessor()

Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-sparsevctrs.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("sparse tibble can be passed to `fit() - recipe", {
skip_if_not_installed("glmnet")
# Make materialization of sparse vectors throw an error
Expand Down Expand Up @@ -140,7 +142,7 @@ test_that("sparse tibble can be passed to `predict()`", {
add_model(spec)

wf_fit <- fit(wf_spec, hotel_data)

expect_no_error(predict(wf_fit, hotel_data))
})

Expand All @@ -166,7 +168,7 @@ test_that("sparse matrix can be passed to `predict()`", {
suppressWarnings(
wf_fit <- fit(wf_spec, hotel_data)
)

expect_no_warning(predict(wf_fit, hotel_data))
})

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-workflow.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

# ------------------------------------------------------------------------------
# workflow()

Expand Down

0 comments on commit 6ee7c0a

Please sign in to comment.