From 1471e2b3a147681c03e98f8f31faef9c3982e66c Mon Sep 17 00:00:00 2001 From: Hugo Gruson <10783929+Bisaloo@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:29:00 +0100 Subject: [PATCH] Only inspect a subset of par() in helper-state --- tests/testthat/helper-state.R | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/testthat/helper-state.R b/tests/testthat/helper-state.R index 4910faa..7f00e43 100644 --- a/tests/testthat/helper-state.R +++ b/tests/testthat/helper-state.R @@ -5,6 +5,14 @@ # function, or more conveniently with the `withr` package. # We add a test on R >= 4.0.0 because some functions such as # `globalCallingHandlers()` did not exist before. +get_pars_toreset <- function() { + pars <- par() + # The following params are set and modified automatically by plot() and we: + # 1. have no control over them + # 2. do not care about resetting them + pars <- pars[!names(pars) %in% c("cxy", "usr", "xaxp")] +} + if (getRversion() >= "4.0.0") { testthat::set_state_inspector(function() { list( @@ -16,7 +24,7 @@ if (getRversion() >= "4.0.0") { libpaths = .libPaths(), locale = Sys.getlocale(), options = options(), - par = par(), + par = get_pars_toreset(), packages = .packages(all.available = TRUE), sink = sink.number(), timezone = Sys.timezone(),