Skip to content

Commit

Permalink
Only inspect a subset of par() in helper-state (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo authored Dec 5, 2024
1 parent 1695802 commit 2b5af2f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/testthat/helper-state.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
# 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(no.readonly = TRUE)
# The following params are set and modified automatically by plot(), as
# documented in ?plot.window() and we:
# 1. have no control over them
# 2. do not care about resetting them
pars <- pars[!names(pars) %in% c("usr", "xaxp", "yaxp")]
}

if (getRversion() >= "4.0.0") {
testthat::set_state_inspector(function() {
list(
Expand All @@ -16,7 +25,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 2b5af2f

Please sign in to comment.