tests/testthat/test-plot.R

test_that("with_par() works", {
  skip_if_not(package_available("graphics"))
  skip_if_not(package_available("grDevices"))

  par0 <- graphics::par("mfrow")
  set.seed(42)
  df <- data.frame(a = stats::rnorm(100), b = stats::rnorm(100))
  # not testing for plot
  grDevices::dev.off()
  wuffle(with_par(
    graphics::plot(stats::lm(a ~ b, data = df)),
    ops = list(mfrow = c(2, 2))
  ))
  grDevices::dev.off()
  expect_identical(par0, graphics::par("mfrow"))
})

Try the mark package in your browser

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

mark documentation built on May 29, 2024, 5:13 a.m.