Skip to content

Commit

Permalink
reducing tests on CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
larmarange committed Feb 9, 2023
1 parent f484a84 commit e13787c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
2 changes: 2 additions & 0 deletions tests/testthat/test-add_header_rows.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ test_that("test tidy_add_header_rows() checks", {
})

test_that("tidy_add_header_rows() works with nnet::multinom", {
skip_on_cran()
mod <- nnet::multinom(grade ~ stage + marker + age + trt, data = gtsummary::trial, trace = FALSE)
res <- mod %>%
tidy_and_attach() %>%
Expand Down Expand Up @@ -201,6 +202,7 @@ test_that("test tidy_add_header_rows() bad single row request", {


test_that("tidy_add_header_rows() and mixed model", {
skip_on_cran()
skip_if_not_installed("lme4")
mod <- lme4::lmer(
age ~ stage + (stage | grade) + (1 | grade),
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-add_n.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ test_that("tidy_add_n() works with lme4::glmer", {


test_that("tidy_add_n() works with survival::coxph", {
skip_on_cran()
df <- survival::lung %>% dplyr::mutate(sex = factor(sex))
mod <- survival::coxph(survival::Surv(time, status) ~ ph.ecog + age + sex, data = df)
expect_error(mod %>% tidy_and_attach() %>% tidy_add_n(), NA)
})

test_that("tidy_add_n() works with survival::survreg", {
skip_on_cran()
mod <- survival::survreg(
survival::Surv(futime, fustat) ~ factor(ecog.ps) + rx,
survival::ovarian,
Expand All @@ -186,6 +188,7 @@ test_that("tidy_add_n() works with survival::survreg", {
})

test_that("tidy_add_n() works with nnet::multinom", {
skip_on_cran()
mod <- nnet::multinom(grade ~ stage + marker + age, data = gtsummary::trial, trace = FALSE)
expect_error(mod %>% tidy_and_attach() %>% tidy_add_n(), NA)

Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-add_reference_rows.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ test_that("tidy_add_reference_rows() use var_label if available", {
})

test_that("tidy_add_reference_rows() works with nnet::multinom", {
skip_on_cran()
mod <- nnet::multinom(grade ~ stage + marker + age, data = gtsummary::trial, trace = FALSE)
res <- mod %>%
tidy_and_attach() %>%
Expand Down Expand Up @@ -247,9 +248,9 @@ test_that("tidy_add_reference_rows() works with lme4::glmer", {


test_that("tidy_add_reference_rows() works with glmmTMB::glmmTMB", {
skip_on_cran()
skip_if_not_installed("glmmTMB")
skip_if_not_installed("broom.mixed")
skip_on_cran()

mod <- glmmTMB::glmmTMB(count ~ mined + spp,
ziformula = ~ mined,
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test-add_term_labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ test_that("tidy_add_term_labels() works with poly or helmert contrasts", {


test_that("tidy_add_term_labels() works with variables having non standard name", {
skip_on_cran()
df <- gtsummary::trial %>% dplyr::rename(
`grade of kids...` = grade,
`?? treatment ++ response ...` = response
Expand Down Expand Up @@ -222,6 +223,7 @@ test_that("tidy_add_term_labels() works with variables having non standard name"


test_that("tidy_add_term_labels() works with stats::poly()", {
skip_on_cran()
df <- iris %>% labelled::set_variable_labels(Petal.Length = "Length of petal")
mod <- lm(Sepal.Length ~ poly(Sepal.Width, 3) + poly(Petal.Length, 2), df)
res <- mod %>%
Expand Down Expand Up @@ -257,12 +259,14 @@ test_that("tidy_add_term_labels() works with lme4::glmer", {


test_that("tidy_add_term_labels() works with survival::coxph", {
skip_on_cran()
df <- survival::lung %>% dplyr::mutate(sex = factor(sex))
mod <- survival::coxph(survival::Surv(time, status) ~ ph.ecog + age + sex, data = df)
expect_error(mod %>% tidy_and_attach() %>% tidy_add_term_labels(), NA)
})

test_that("tidy_add_term_labels() works with survival::survreg", {
skip_on_cran()
mod <- survival::survreg(
survival::Surv(futime, fustat) ~ ecog.ps + rx,
survival::ovarian,
Expand All @@ -272,36 +276,42 @@ test_that("tidy_add_term_labels() works with survival::survreg", {
})

test_that("tidy_add_term_labels() works with nnet::multinom", {
skip_on_cran()
mod <- nnet::multinom(grade ~ stage + marker + age, data = gtsummary::trial, trace = FALSE)
expect_error(mod %>% tidy_and_attach() %>% tidy_add_term_labels(), NA)
})

test_that("tidy_add_term_labels() works with survey::svyglm", {
skip_on_cran()
skip_if_not_installed("survey")
df <- survey::svydesign(~1, weights = ~1, data = gtsummary::trial)
mod <- survey::svyglm(response ~ age + grade * trt, df, family = quasibinomial)
expect_error(mod %>% tidy_and_attach() %>% tidy_add_term_labels(), NA)
})

test_that("tidy_add_term_labels() works with ordinal::clm", {
skip_on_cran()
mod <- ordinal::clm(rating ~ temp * contact, data = ordinal::wine)
expect_error(mod %>% tidy_and_attach() %>% tidy_add_term_labels(), NA)
})


test_that("tidy_add_term_labels() works with ordinal::clmm", {
skip_on_cran()
mod <- ordinal::clmm(rating ~ temp * contact + (1 | judge), data = ordinal::wine)
expect_error(mod %>% tidy_and_attach() %>% tidy_add_term_labels(), NA)
})


test_that("tidy_add_term_labels() works with MASS::polr", {
skip_on_cran()
mod <- MASS::polr(Sat ~ Infl + Type + Cont, weights = Freq, data = MASS::housing)
expect_error(mod %>% tidy_and_attach() %>% tidy_add_term_labels(), NA)
})


test_that("tidy_add_term_labels() works with geepack::geeglm", {
skip_on_cran()
skip_if(packageVersion("geepack") < 1.3)

df <- geepack::dietox
Expand All @@ -315,6 +325,7 @@ test_that("tidy_add_term_labels() works with geepack::geeglm", {


test_that("tidy_add_term_labels() works with gam::gam", {
skip_on_cran()
skip_if_not_installed("gam")
data(kyphosis, package = "gam")
mod <- gam::gam(Kyphosis ~ gam::s(Age, 4) + Number, family = binomial, data = kyphosis)
Expand All @@ -329,6 +340,7 @@ test_that("tidy_add_term_labels() works with gam::gam", {


test_that("tidy_add_term_labels() works with lavaan::lavaan", {
skip_on_cran()
skip_if_not_installed("lavaan")
df <- lavaan::HolzingerSwineford1939
df$grade <- factor(df$grade, ordered = TRUE)
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-model_get_n.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ test_that("model_get_n() works with different contrasts", {


test_that("model_get_n() works with stats::poly()", {
skip_on_cran()
mod <- lm(Sepal.Length ~ poly(Sepal.Width, 3) + poly(Petal.Length, 2), iris)
expect_error(res <- mod %>% model_get_n(), NA)
expect_equivalent(names(res), c("term", "n_obs"))
Expand Down Expand Up @@ -224,6 +225,7 @@ test_that("model_get_n() works with lme4::glmer", {


test_that("model_get_n() works with survival::coxph", {
skip_on_cran()
df <- survival::lung %>% dplyr::mutate(sex = factor(sex))
mod <- survival::coxph(survival::Surv(time, status) ~ ph.ecog + age + sex, data = df)
expect_error(res <- mod %>% model_get_n(), NA)
Expand All @@ -244,6 +246,7 @@ test_that("model_get_n() works with survival::coxph", {
})

test_that("model_get_n() works with survival::survreg", {
skip_on_cran()
mod <- survival::survreg(
survival::Surv(futime, fustat) ~ factor(ecog.ps) + rx,
survival::ovarian,
Expand All @@ -254,6 +257,7 @@ test_that("model_get_n() works with survival::survreg", {
})

test_that("model_get_n() works with nnet::multinom", {
skip_on_cran()
mod <- nnet::multinom(grade ~ stage + marker + age, data = gtsummary::trial, trace = FALSE)
expect_error(res <- mod %>% model_get_n(), NA)
expect_equivalent(names(res), c("y.level", "term", "n_obs", "n_event"))
Expand All @@ -277,6 +281,7 @@ test_that("model_get_n() works with nnet::multinom", {
})

test_that("model_get_n() works with survey::svyglm", {
skip_on_cran()
skip_if_not_installed("survey")
df <- survey::svydesign(~1, weights = ~1, data = gtsummary::trial)
mod <- survey::svyglm(response ~ age + grade * trt, df, family = quasibinomial)
Expand All @@ -301,6 +306,7 @@ test_that("model_get_n() works with survey::svyglm", {
})

test_that("model_get_n() works with ordinal::clm", {
skip_on_cran()
mod <- ordinal::clm(rating ~ temp * contact, data = ordinal::wine)
expect_error(res <- mod %>% model_get_n(), NA)
expect_equivalent(names(res), c("term", "n_obs"))
Expand All @@ -309,20 +315,23 @@ test_that("model_get_n() works with ordinal::clm", {


test_that("model_get_n() works with ordinal::clmm", {
skip_on_cran()
mod <- ordinal::clmm(rating ~ temp * contact + (1 | judge), data = ordinal::wine)
expect_error(res <- mod %>% model_get_n(), NA)
expect_equivalent(names(res), c("term", "n_obs"))
})


test_that("model_get_n() works with MASS::polr", {
skip_on_cran()
mod <- MASS::polr(Sat ~ Infl + Type + Cont, weights = Freq, data = MASS::housing)
expect_error(res <- mod %>% model_get_n(), NA)
expect_equivalent(names(res), c("term", "n_obs"))
})


test_that("model_get_n() works with geepack::geeglm", {
skip_on_cran()
skip_if(packageVersion("geepack") < 1.3)

df <- geepack::dietox
Expand All @@ -343,6 +352,7 @@ test_that("model_get_n() works with geepack::geeglm", {


test_that("model_get_n() works with gam::gam", {
skip_on_cran()
skip_if_not_installed("gam")
data(kyphosis, package = "gam")
mod <- gam::gam(Kyphosis ~ gam::s(Age, 4) + Number, family = binomial, data = kyphosis)
Expand All @@ -352,6 +362,7 @@ test_that("model_get_n() works with gam::gam", {


test_that("model_get_n() works with lavaan::lavaan", {
skip_on_cran()
skip_if_not_installed("lavaan")
df <- lavaan::HolzingerSwineford1939
df$grade <- factor(df$grade, ordered = TRUE)
Expand Down
13 changes: 10 additions & 3 deletions tests/testthat/test-tidy_plus_plus.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ test_that("tidy_plus_plus() works with no intercept models", {
})

test_that("tidy_plus_plus() and functionnal programming", {
skip_on_cran()
# works with glm
expect_error(
res <- dplyr::tibble(grade = c("I", "II", "III")) %>%
Expand Down Expand Up @@ -122,6 +123,7 @@ test_that("tidy_plus_plus() with mice objects", {


test_that("tidy_plus_plus() with tidyselect", {
skip_on_cran()
# build regression model
mod <- lm(age ~ trt + marker + grade, gtsummary::trial)

Expand Down Expand Up @@ -152,6 +154,7 @@ test_that("tidy_plus_plus() with tidyselect", {
})

test_that("tidy_plus_plus() works with stats::aov", {
skip_on_cran()
mod <- aov(yield ~ block + N * P * K, npk)
expect_error(
res <- tidy_plus_plus(mod),
Expand Down Expand Up @@ -212,6 +215,7 @@ test_that("tidy_plus_plus() works with lme4::glmer.nb", {
})

test_that("tidy_plus_plus() works with survival::coxph", {
skip_on_cran()
df <- survival::lung %>% dplyr::mutate(sex = factor(sex))
mod <- survival::coxph(survival::Surv(time, status) ~ ph.ecog + age + sex, data = df)
expect_error(
Expand All @@ -221,6 +225,7 @@ test_that("tidy_plus_plus() works with survival::coxph", {
})

test_that("tidy_plus_plus() works with survival::survreg", {
skip_on_cran()
mod <- survival::survreg(
survival::Surv(futime, fustat) ~ ecog.ps + rx,
survival::ovarian,
Expand Down Expand Up @@ -289,8 +294,8 @@ test_that("tidy_plus_plus() works with nnet::multinom", {
})

test_that("tidy_plus_plus() works with survey::svyglm", {
skip_if_not_installed("survey")
skip_on_cran()
skip_if_not_installed("survey")
df <- survey::svydesign(~1, weights = ~1, data = gtsummary::trial)
mod <- survey::svyglm(response ~ age + grade * trt, df, family = quasibinomial)
expect_error(
Expand All @@ -300,8 +305,8 @@ test_that("tidy_plus_plus() works with survey::svyglm", {
})

test_that("tidy_plus_plus() works with survey::svycoxph", {
skip_if_not_installed("survey")
skip_on_cran()
skip_if_not_installed("survey")
dpbc <- survey::svydesign(id = ~ 1, prob = ~ 1, strata = ~ edema, data = survival::pbc)
mod <- survey::svycoxph(
Surv(time, status > 0) ~ log(bili) + protime + albumin,
Expand All @@ -314,8 +319,8 @@ test_that("tidy_plus_plus() works with survey::svycoxph", {
})

test_that("tidy_plus_plus() works with survey::svyolr", {
skip_if_not_installed("survey")
skip_on_cran()
skip_if_not_installed("survey")
data(api, package = "survey")
fpc <- survey::svydesign(id = ~ dnum, weights = ~ pw, data = apiclus1, fpc = ~ fpc)
fpc <- update(fpc, mealcat = cut(meals, c(0, 25, 50, 75, 100)))
Expand Down Expand Up @@ -347,6 +352,7 @@ test_that("tidy_plus_plus() works with ordinal::clmm", {


test_that("tidy_plus_plus() works with MASS::polr", {
skip_on_cran()
mod <- MASS::polr(Sat ~ Infl + Type + Cont, weights = Freq, data = MASS::housing)
expect_error(
res <- mod %>% tidy_plus_plus(),
Expand Down Expand Up @@ -454,6 +460,7 @@ test_that("tidy_plus_plus() works with tidycmprsk::crr", {


test_that("tidy_plus_plus() works with stats::nls", {
skip_on_cran()
mod <- stats::nls(
Petal.Width ~ a * Petal.Length - (Sepal.Width + Sepal.Length) / b + a^2,
data = iris,
Expand Down

0 comments on commit e13787c

Please sign in to comment.