Skip to content

Commit 41442ac

Browse files
krlmlrlionel-
andauthored
Align with withr::local_language() from dev withr (#1879)
Co-authored-by: Lionel Henry <[email protected]>
1 parent 75c70e0 commit 41442ac

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Imports:
3535
rlang (>= 1.1.1),
3636
utils,
3737
waldo (>= 0.5.1),
38-
withr (>= 2.5.0)
38+
withr (>= 3.0.2)
3939
Suggests:
4040
covr,
4141
curl (>= 0.9.5),
@@ -55,4 +55,4 @@ Config/testthat/parallel: true
5555
Config/testthat/start-first: watcher, parallel*
5656
Encoding: UTF-8
5757
Roxygen: list(markdown = TRUE, r6 = FALSE)
58-
RoxygenNote: 7.2.3
58+
RoxygenNote: 7.3.2

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# testthat (development version)
22

3+
* `LANGUAGE` is now set to `"C"` in reprocucible environments (i.e.
4+
`test_that()` blocks) to disable translations. This fixes warnings
5+
about being unable to set the language to `"en"` (#1925).
6+
37
# testthat 3.2.1
48

59
* Fix incorrect format string detected by latest R-devel. Fix thanks to

R/local.R

+2-5
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ local_reproducible_output <- function(width = 80,
9898
unicode = FALSE,
9999
rstudio = FALSE,
100100
hyperlinks = FALSE,
101-
lang = "en",
101+
lang = "C",
102102
.env = parent.frame()) {
103103

104104
if (unicode) {
@@ -133,10 +133,7 @@ local_reproducible_output <- function(width = 80,
133133
.local_envir = .env
134134
)
135135

136-
if (isTRUE(capabilities("NLS")) && Sys.getenv("LANG") != "C") {
137-
withr::local_language(lang, .local_envir = .env)
138-
}
139-
136+
withr::local_language(lang, .local_envir = .env)
140137
withr::local_collate("C", .local_envir = .env)
141138
}
142139

man/local_test_context.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-local.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test_that("local context is 'as promised' inside test_that()", {
2121
expect_equal(getOption("max.print"), 99999)
2222

2323
expect_equal(Sys.getenv("RSTUDIO"), "")
24-
expect_equal(Sys.getenv("LANGUAGE"), "en")
24+
expect_equal(Sys.getenv("LANGUAGE"), "C")
2525

2626
expect_equal(Sys.getlocale("LC_COLLATE"), "C")
2727
})

0 commit comments

Comments
 (0)