Skip to content

Commit

Permalink
Merge pull request #45 from bedapub/tighten-seed-test
Browse files Browse the repository at this point in the history
Only touch .Random.seed in .GlobalEnv
  • Loading branch information
banfai authored Mar 19, 2024
2 parents b796e5c + 9479cc2 commit f2abf52
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/testthat/test-save-random-seed.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ scoring_f <- function(...) rnorm(1)

test_that("random seed is saved when no seed is set", {
# unset random seed
if (exists(".Random.seed")) {
random_seed <- .Random.seed
if (exists(".Random.seed", envir = .GlobalEnv)) {
random_seed <- .GlobalEnv$.Random.seed
on.exit(.GlobalEnv$.Random.seed <- random_seed)
rm(.Random.seed, envir = .GlobalEnv)
testthat::expect_false(exists(".Random.seed"))
Expand Down

0 comments on commit f2abf52

Please sign in to comment.