tests/testthat/test-python-import-hook.R

context("imports")

test_that("The reticulate import hook handles recursive imports", {

  skip_if_no_matplotlib()

  R <- file.path(R.home("bin"), "R")
  script <- "resources/import-test.R"
  args <- c("--no-save", "--no-restore", "-s", "-f", shQuote(script))
  output <- system2(R, args, stdout = TRUE, stderr = TRUE)

  pattern <- "Loaded module '(.*)'"
  modules <- gsub(pattern, "\\1", output)
  expect_true("matplotlib.pyplot" %in% modules)

})

Try the reticulate package in your browser

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

reticulate documentation built on Sept. 11, 2024, 8:31 p.m.