Skip to content

Commit

Permalink
Only inspect a subset of par() in helper-state
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo committed Dec 5, 2024
1 parent 36324bc commit 1471e2b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/testthat/helper-state.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(),
Expand Down

0 comments on commit 1471e2b

Please # to comment.