Skip to content

Commit a8be18e

Browse files
authored
Only use part of local_reproducible_output() in Reporter$local_user_output() (#1525)
Fixes #1285
1 parent a0dafdf commit a8be18e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# testthat (development version)
22

3+
* `test_that()` no longer inappropriately skips when calling `expect_equal()`
4+
when you've temporarily set the locale to non-UTF-8 (#1285).
5+
36
* When a snapshot changes the hint also mentions that you can use
47
`snapshot_review()` (#1500, @DanChaltiel).
58

R/reporter.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ Reporter <- R6::R6Class("Reporter",
6666
local_reproducible_output(
6767
width = self$width,
6868
crayon = self$crayon,
69-
unicode = self$unicode,
7069
.env = .env
7170
)
71+
# Can't set unicode with local_reproducible_output() because it can
72+
# generate a skip if you're temporarily using a non-UTF-8 locale
73+
withr::local_options(cli.unicode = self$unicode, .local_envir = .env)
7274
},
7375

7476
cat_tight = function(...) {

tests/testthat/test-reporter.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ test_that("can control output with file arg/option", {
1616
)
1717
expect_snapshot_output(readLines(path))
1818
})
19+
20+
test_that("should not automatically skip in non-utf-8 locales", {
21+
withr::local_locale(LC_CTYPE = "C")
22+
expect_true(TRUE)
23+
})

0 commit comments

Comments
 (0)