Skip to content

Commit

Permalink
Skip tests if deepforest not present instead of skipping on CRAN
Browse files Browse the repository at this point in the history
This lets tests run on CI and follows recommend practice:
https://rstudio.github.io/reticulate/articles/package.html#checking-and-testing-on-cran
  • Loading branch information
ethanwhite committed Jul 13, 2024
1 parent eb538e3 commit f674ba2
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions tests/testthat/test-integration.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -65,4 +49,4 @@ test_that("training works", {
model$create_trainer()
model$trainer$fit(model)
expect_type(model, "closure")
})
})

0 comments on commit f674ba2

Please sign in to comment.