From 8d05cfe5e3ea33231385e6fe9383e223fb98c827 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Tue, 8 Aug 2023 14:06:59 -0700 Subject: [PATCH 1/2] namespace functions in tests --- tests/testthat/test-autoplot.R | 13 ++++++------- tests/testthat/test-last-fit.R | 3 +-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/testthat/test-autoplot.R b/tests/testthat/test-autoplot.R index 6d165afbc..525834e83 100644 --- a/tests/testthat/test-autoplot.R +++ b/tests/testthat/test-autoplot.R @@ -193,11 +193,10 @@ test_that("regular grid plot", { test_that("coord_obs_pred", { data(solubility_test, package = "modeldata") - library(ggplot2) p <- - ggplot(solubility_test, aes(x = solubility, y = prediction)) + - geom_abline(lty = 2) + - geom_point(alpha = 0.5) + ggplot2::ggplot(solubility_test, ggplot2::aes(x = solubility, y = prediction)) + + ggplot2::geom_abline(lty = 2) + + ggplot2::geom_point(alpha = 0.5) rng <- range(solubility_test[[1]], solubility_test[[2]]) @@ -212,9 +211,9 @@ test_that("coord_obs_pred", { solubility_test$solubility[1] <- NA p3 <- - ggplot(solubility_test, aes(x = solubility, y = prediction)) + - geom_abline(lty = 2) + - geom_point(alpha = 0.5) + ggplot2::ggplot(solubility_test, ggplot2::aes(x = solubility, y = prediction)) + + ggplot2::geom_abline(lty = 2) + + ggplot2::geom_point(alpha = 0.5) expect_snapshot_warning(print(p3 + coord_obs_pred())) }) diff --git a/tests/testthat/test-last-fit.R b/tests/testthat/test-last-fit.R index 2595ec59f..59b2a7887 100644 --- a/tests/testthat/test-last-fit.R +++ b/tests/testthat/test-last-fit.R @@ -68,9 +68,8 @@ test_that("model_fit method", { test_that("workflow method", { library(parsnip) - library(workflows) - lm_fit <- workflow(mpg ~ ., linear_reg()) %>% fit(data = mtcars) + lm_fit <- workflows::workflow(mpg ~ ., linear_reg()) %>% fit(data = mtcars) expect_snapshot(last_fit(lm_fit), error = TRUE) }) From f908be1a894827f0efca7f0878c7b481f1b04386 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Tue, 8 Aug 2023 14:07:16 -0700 Subject: [PATCH 2/2] add missing suppressPackageStartupMessages() --- tests/testthat/test-censored-reg.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-censored-reg.R b/tests/testthat/test-censored-reg.R index 0e1106741..1bf383c69 100644 --- a/tests/testthat/test-censored-reg.R +++ b/tests/testthat/test-censored-reg.R @@ -3,7 +3,7 @@ test_that("evaluation time", { skip_if_not_installed("yardstick", minimum_version = "1.1.0.9000") suppressPackageStartupMessages(library(tune)) - library(censored) + suppressPackageStartupMessages(library(censored)) suppressPackageStartupMessages(library(yardstick)) suppressPackageStartupMessages(library(rsample))