tidymodels / extratests

Integration and other testing for tidymodels
Other
20 stars 1 forks source link

Thinking about how we test parsnip model registration with extension packages #186

Open EmilHvitfeldt opened 9 months ago

EmilHvitfeldt commented 9 months ago

This is related to #185. Which was darn hard to figure out.

What happens is that the .onload() of baguette will trigger in a test. Which is what we want. But it will stay triggered for any of the following tests. Such that we get different results sometimes depending on if we test all files or one file. Also, it violates some soft of test smell, since the order of tests matter

library(parsnip)
library(testthat)

parsnip::get_model_env()$bag_tree_args
#> # A tibble: 0 × 5
#> # ℹ 5 variables: engine <chr>, parsnip <chr>, original <chr>, func <list>,
#> #   has_submodel <lgl>

# could be in a previous file
test_that("load baguette", {
  library(baguette)
})
#> ── Skip: load baguette ─────────────────────────────────────────────────────────
#> Reason: empty test

parsnip::get_model_env()$bag_tree_args
#> # A tibble: 6 × 5
#>   engine parsnip         original func             has_submodel
#>   <chr>  <chr>           <chr>    <list>           <lgl>       
#> 1 rpart  class_cost      cost     <named list [2]> FALSE       
#> 2 rpart  tree_depth      maxdepth <named list [2]> FALSE       
#> 3 rpart  min_n           minsplit <named list [2]> FALSE       
#> 4 rpart  cost_complexity cp       <named list [2]> FALSE       
#> 5 C5.0   class_cost      cost     <named list [2]> FALSE       
#> 6 C5.0   min_n           minCases <named list [2]> FALSE