Skip to content

Commit

Permalink
delete references to .GlobalEnv in test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
berthetclement committed Jul 25, 2024
1 parent 30938f7 commit b088382
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
33 changes: 12 additions & 21 deletions tests/testthat/helper_init.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

path0 <- tempdir()

#sourcedir <- system.file("inst/testdata", package = "antaresRead")
sourcedir <- system.file("testdata", package = "antaresRead")

#if(sourcedir == ""){ }

## force tests to be executed if in dev release which we define as
## having a sub-release, eg 0.9.15.5 is one whereas 0.9.16 is not
Expand Down Expand Up @@ -58,16 +56,13 @@ if (sourcedir != "") {
untar(file.path(sourcedir, studies[s]), exdir = file.path(path0, studies_names[s]))
}

assign(
x = "studyPathS",
value = file.path(path0, studies_names, "test_case"),
envir = globalenv()
)
studyPathS <- file.path(path0, studies_names, "test_case")

nweeks <- 2
nmonths <- 2
firstDay <- 113
lastDay <- 126

assign("nweeks", 2, envir = globalenv())
assign("nmonths", 2, envir = globalenv())
assign("firstDay", 113, envir = globalenv())
assign("lastDay", 126, envir = globalenv())
}


Expand All @@ -92,11 +87,8 @@ if(sourcedir_V8 != ""){
dir.create(file.path(path0, studies_names[s]))
untar(file.path(sourcedir_V8, studies[s]), exdir = file.path(path0, studies_names[s]))
}
assign(
x = "studyPathSV8",
value = file.path(path0, studies_names, "test_case"),
envir = globalenv()
)

studyPathSV8 <- file.path(path0, studies_names, "test_case")
}


Expand Down Expand Up @@ -132,8 +124,7 @@ setup_study_empty <- function(dir_path){
untar(studies[1], exdir = path_sty) # version latest
study_temp_path <- file.path(path_sty, "test_case")

assign("study_empty_latest_version",
file.path(path_sty,
"test_case"),
envir = globalenv())
}
study_empty_latest_version <- file.path(path_sty,
"test_case")
return(study_empty_latest_version)
}
2 changes: 1 addition & 1 deletion tests/testthat/test-readBindingConstraints.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test_that("test if exist data value file", {
# >= v870 ----

# read latest version of empty study
setup_study_empty(sourcedir_empty_study)
study_empty_latest_version <- setup_study_empty(sourcedir_empty_study)
opts_test_empty <- antaresRead::setSimulationPath(study_empty_latest_version,
"input")

Expand Down

0 comments on commit b088382

Please sign in to comment.