diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index a578e48..2a2f81f 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -2,47 +2,33 @@ library(testthat) context("integration tests for DeepForest in R") -test_that("deepforest model is installed", { - - # Python package not installed on CRAN - - skip_on_cran() +skip_if_no_deepforest <- function() { + deepforest_avail <- py_module_available("deepforest") + if (!deepforest) + skip("deepforest not available for testing") +} +test_that("deepforest model is installed", { + skip_if_no_deepforest() deepforest_available = reticulate::py_module_available("deepforest") expect_identical(deepforest_available, TRUE) }) test_that("deepforest model exists when loaded", { - - # Python package not installed on CRAN - - skip_on_cran() - + skip_if_no_deepforest() model = df_model() expect_type(model, "closure") - }) test_that("use_release model exists when loaded", { - - # Python package not installed on CRAN - - skip_on_cran() - + skip_if_no_deepforest() model = df_model() model$use_release() expect_type(model, "closure") - }) test_that("image prediction works", { - - # Python package not installed on CRAN - - skip_on_cran() - - expect - + skip_if_no_deepforest() model = df_model() model$use_release() image_path = get_data("OSBS_029.png") @@ -51,9 +37,7 @@ test_that("image prediction works", { }) test_that("training works", { - - skip_on_cran() - + skip_if_no_deepforest() model = df_model() model$use_release() annotations_file = get_data("testfile_deepforest.csv") @@ -65,4 +49,4 @@ test_that("training works", { model$create_trainer() model$trainer$fit(model) expect_type(model, "closure") -}) \ No newline at end of file +})