diff --git a/DESCRIPTION b/DESCRIPTION index 02fb8e59..e1a3e565 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,7 +48,8 @@ Imports: rlang, testthat, utils, - xml2 + xml2, + withr Suggests: baseline, bookdown, diff --git a/R/DEPRECATED-read.mat.Witec.R b/R/DEPRECATED-read.mat.Witec.R index 7eec132e..af1d2700 100644 --- a/R/DEPRECATED-read.mat.Witec.R +++ b/R/DEPRECATED-read.mat.Witec.R @@ -57,7 +57,10 @@ hySpc.testthat::test(read.mat.Witec) <- function() { test_that( "deprecated", expect_warning( - expect_error(read.mat.Witec(file = ""), "Can only read a MAT file"), + expect_error( + with_envvar(list(LANGUAGE = "en_US"), read.mat.Witec(file = "")), + "Can only read a MAT file" + ), "deprecated|supports" ) ) diff --git a/R/DEPRECATED-read.spc.R b/R/DEPRECATED-read.spc.R index 2600832a..9ed908ed 100644 --- a/R/DEPRECATED-read.spc.R +++ b/R/DEPRECATED-read.spc.R @@ -855,7 +855,10 @@ hySpc.testthat::test(read.spc) <- function() { test_that( "deprecated", expect_warning( - expect_error(read.spc(file = ""), "can only read"), + expect_error( + with_envvar(list(LANGUAGE = "en_US"), read.spc(file = "")), + "can only read" + ), "deprecated" ) ) diff --git a/R/DEPRECATED-read.spe.R b/R/DEPRECATED-read.spe.R index 20ca1d0f..e69286ed 100644 --- a/R/DEPRECATED-read.spe.R +++ b/R/DEPRECATED-read.spe.R @@ -361,7 +361,10 @@ hySpc.testthat::test(read.spe) <- function() { test_that( "deprecated", expect_warning( - expect_error(read.spe(filename = ""), "can only read"), + expect_error( + with_envvar(list(LANGUAGE = "en_US"), read.spe(filename = "")), + "can only read" + ), "deprecated" ) ) diff --git a/R/DEPRECATED-read.txt.Renishaw.R b/R/DEPRECATED-read.txt.Renishaw.R index 3746e004..e283e540 100644 --- a/R/DEPRECATED-read.txt.Renishaw.R +++ b/R/DEPRECATED-read.txt.Renishaw.R @@ -172,7 +172,10 @@ hySpc.testthat::test(read.txt.Renishaw) <- function() { test_that( "deprecated", expect_warning( - expect_error(read.txt.Renishaw(file = ""), "cannot open"), + expect_error( + with_envvar(list(LANGUAGE = "en_US"), read.txt.Renishaw(file = "")), + "cannot open" + ), "deprecated" ) ) @@ -199,7 +202,13 @@ hySpc.testthat::test(read.zip.Renishaw) <- function() { test_that( "deprecated", expect_warning( - expect_error(read.zip.Renishaw(file = ""), "cannot open"), + expect_error( + with_envvar( + list(LANGUAGE = "en_US"), + read.zip.Renishaw(file = "") + ), + "cannot open" + ), "deprecated" ) ) diff --git a/R/DEPRECATED-read.txt.Shimadzu.R b/R/DEPRECATED-read.txt.Shimadzu.R index 7559f405..a611dd6c 100644 --- a/R/DEPRECATED-read.txt.Shimadzu.R +++ b/R/DEPRECATED-read.txt.Shimadzu.R @@ -232,7 +232,10 @@ hySpc.testthat::test(read.txt.Shimadzu) <- function() { test_that( "deprecated", expect_warning( - expect_error(read.txt.Shimadzu(file = ""), "attempt to select"), + expect_error( + with_envvar(list(LANGUAGE = "en_US"), read.txt.Shimadzu(file = "")), + "attempt to select" + ), "deprecated" ) ) diff --git a/R/plot.R b/R/plot.R index 6bc2134a..e036e2a4 100644 --- a/R/plot.R +++ b/R/plot.R @@ -156,6 +156,7 @@ setGeneric("plot") #' @concept plot generation #' #' @export +#' @importFrom withr with_envvar #' @examples #' #' plot(flu) @@ -199,7 +200,10 @@ hySpc.testthat::test(.plot) <- function() { expect_warning(plot(hy_spectra, "c"), "Intensity at first wavelengh only is used.") # Regular tests: errors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - expect_error(plot(hy_spectra, "depth"), "object 'z' not found") + expect_error( + with_envvar(list(LANGUAGE = "en_US"), plot(hy_spectra, "depth")), + "object 'z' not found" + ) expect_error(plot(hy_spectra[0, ]), "No spectra.") expect_error(plot(hy_spectra, xoffset = "a"), "xoffset must be a numeric") expect_error(plot(hy_spectra, func = "a"), "func needs to be a function")