tests/testthat/setup.R

if (isTRUE(as.logical(Sys.getenv("NOT_CRAN", "false")))) {
  # Get a name for this test run
  timestamp <- format(Sys.time(), "%Y%m%d%H%M%S")
  test_name <- paste0("laminr-test-", timestamp)

  # Make sure we are using the ephemeral environment with lamindb
  withr::with_envvar(
    c("RETICULATE_USE_MANAGED_VENV" = "yes"),
    {
      require_lamindb()
      reticulate::py_config()
    }
  )

  # Use a temporary test instance
  use_temporary_instance(
    test_name,
    modules = c("bionty", "pertdb"),
    add_timestamp = FALSE,
    envir = testthat::teardown_env()
  )

  # Import lamindb so we don't have to do it in every test
  ln <- import_module("lamindb")

  # Reset the default instance so we can connect to another
  withr::defer(options(LAMINR_DEFAULT_INSTANCE = NULL), testthat::teardown_env())
}

Try the laminr package in your browser

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

laminr documentation built on March 13, 2026, 5:08 p.m.