tests/testthat/test-unsupported.R

# Classes that inherit an apa7 method that does not fit them give an error
# instead of a table with wrong labels. The errors depend only on the class,
# so objects with the class of a tobit model (AER) or a survey-weighted GLM
# (survey) stand in for real ones, without those packages.

test_that("conditional logistic regression models give an error", {
  skip_if_not_installed("survival")
  # clogit() calls coxph() without its namespace, so survival must be attached
  withr::local_package("survival")
  fit <- survival::clogit(
    case ~ spontaneous + induced + survival::strata(stratum),
    data = infert
  )
  expect_error(apa_parameters(fit), "Conditional logistic regression")
  expect_error(apa_performance(fit), "not supported yet")
  expect_error(apa_parameters(list(fit, fit)), "Conditional logistic regression")
  expect_error(apa_performance_comparison(fit, fit), "Conditional logistic regression")
})

test_that("tobit models give an error", {
  fit <- structure(list(), class = c("tobit", "survreg"))
  expect_error(apa_parameters(fit), "Tobit models")
  expect_error(apa_performance(fit), "not supported yet")
  expect_error(apa_performance_comparison(fit, fit), "Tobit models")
})

test_that("survey-weighted GLMs give an error", {
  fit <- structure(list(), class = c("svyglm", "glm", "lm"))
  expect_error(apa_parameters(fit), "Survey-weighted")
  expect_error(apa_performance(fit), "survey design")
})

Try the apa7 package in your browser

Any scripts or data that you put into this service are public.

apa7 documentation built on Dec. 1, 2026, 5:06 p.m.