Skip to content

Commit 8cd37ba

Browse files
committed
Merge branch 'main' into feature/add-recursive-dirs
2 parents 9b608c5 + fe50a22 commit 8cd37ba

31 files changed

+1388
-94
lines changed

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: testthat
22
Title: Unit Testing for R
3-
Version: 3.2.0.9001
3+
Version: 3.2.1.9001
44
Authors@R: c(
55
person("Hadley", "Wickham", , "[email protected]", role = c("aut", "cre")),
66
person("Posit Software, PBC", role = c("cph", "fnd")),
@@ -22,7 +22,6 @@ Imports:
2222
cli (>= 3.6.1),
2323
desc (>= 1.4.2),
2424
digest (>= 0.6.33),
25-
ellipsis (>= 0.3.2),
2625
evaluate (>= 0.21),
2726
jsonlite (>= 1.8.7),
2827
lifecycle (>= 1.0.3),

NEWS.md

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

33
* `test_dir()` gains a `recursive` argument which allows test files in nested directories (#1605).
4+
# testthat 3.2.1
5+
6+
* Fix incorrect format string detected by latest R-devel. Fix thanks to
7+
Tomas Kalibera.
8+
9+
* `expect_snapshot()` handles unexpected errors like errors outside of
10+
snapshots, i.e. they terminate the entire test and get a traceback (#1906).
411

512
* `JunitReporter()` now uses ensures numeric values are saved the xml file
613
with `.` as decimal separator. (@maksymiuks, #1660)
714

15+
* `local_mocked_bindings()` can now mock any object, not just functions
16+
(#1896).
17+
18+
* `skip_if_offline()` now uses `captive.apple.com` by default. This is the
19+
hostname that Apple devices use to check that they're online so it should
20+
have a higher reliability than `r-project.org` (@jdblischak, #1890).
21+
22+
* `test_file(desc = )` will now find `describe()` tests as well as `test_that()`
23+
tests (#1903).
24+
825
# testthat 3.2.0
926

1027
## Lifecycle changes

R/deprec-condition.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ get_messages <- function(x) {
129129
#' has been deprecated.
130130
#'
131131
#' @param x An error object.
132-
#' @inheritParams ellipsis::dots_empty
132+
#' @inheritParams rlang::args_dots_empty
133133
#'
134134
#' @details
135135
#' A few classes are hard-coded as uninformative:

R/expect-condition.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,11 @@ expect_condition_matching <- function(base_class,
254254
inherit = TRUE,
255255
info = NULL,
256256
label = NULL,
257-
trace_env = caller_env()) {
258-
ellipsis::check_dots_used(action = warn)
257+
trace_env = caller_env(),
258+
error_call = caller_env()) {
259+
check_dots_used(error = function(cnd) {
260+
warn(conditionMessage(cnd), call = error_call)
261+
})
259262

260263
matcher <- cnd_matcher(
261264
base_class,

R/mock2.R

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@
9393
#' )
9494
#' ```
9595
#' @export
96-
#' @param ... Name-value pairs providing functions to mock.
96+
#' @param ... Name-value pairs providing new values (typically functions) to
97+
#' temporarily replace the named bindings.
9798
#' @param code Code to execute with specified bindings.
9899
#' @param .env Environment that defines effect scope. For expert use only.
99100
#' @param .package The name of the package where mocked functions should be
@@ -195,14 +196,6 @@ check_bindings <- function(x, error_call = caller_env()) {
195196
call = error_call
196197
)
197198
}
198-
199-
is_fun <- map_lgl(x, is.function)
200-
if (!any(is_fun)) {
201-
cli::cli_abort(
202-
"All elements of {.arg ...} must be functions.",
203-
call = error_call
204-
)
205-
}
206199
}
207200

208201
# For testing -------------------------------------------------------------
@@ -244,6 +237,8 @@ show_bindings <- function(name, env = caller_env()) {
244237
invisible()
245238
}
246239

240+
test_mock_value <- 10
241+
247242
env_desc <- function(env) {
248243
cat(obj_address(env), ": ", env_name(env), "\n", sep = "")
249244
}

R/reporter-junit.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ JunitReporter <- R6::R6Class("JunitReporter",
5656
},
5757

5858
start_reporter = function() {
59-
check_installed("xml2", "JunitReporter")
59+
check_installed("xml2", "to use JunitReporter")
6060

6161
self$timer <- private$proctime()
6262
self$doc <- xml2::xml_new_document()

R/skip.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ package_version <- function(x) {
122122

123123
#' @export
124124
#' @rdname skip
125-
skip_if_offline <- function(host = "r-project.org") {
125+
skip_if_offline <- function(host = "captive.apple.com") {
126126
skip_on_cran()
127127
check_installed("curl")
128128

R/snapshot-manage.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ snapshot_accept <- function(files = NULL, path = "tests/testthat") {
2929
#' @rdname snapshot_accept
3030
#' @export
3131
snapshot_review <- function(files = NULL, path = "tests/testthat") {
32-
check_installed("shiny", "snapshot_review()")
33-
check_installed("diffviewer", "snapshot_review()")
32+
check_installed(c("shiny", "diffviewer"), "to use snapshot_review()")
3433

3534
changed <- snapshot_meta(files, path)
3635
if (nrow(changed) == 0) {

R/snapshot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ expect_snapshot <- function(x,
9494
if (error) {
9595
expect(FALSE, msg, trace = state$error[["trace"]])
9696
} else {
97-
exp_signal(expectation("error", msg, trace = state$error[["trace"]]))
97+
cnd_signal(state$error)
9898
}
9999
return()
100100
}

R/source.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ filter_desc <- function(exprs, desc = NULL, error_call = caller_env()) {
7171
for (i in seq_along(exprs)) {
7272
expr <- exprs[[i]]
7373

74-
if (!is_call(expr, "test_that", n = 2)) {
74+
if (!is_call(expr, c("test_that", "describe"), n = 2)) {
7575
if (!found) {
7676
include[[i]] <- TRUE
7777
}

0 commit comments

Comments
 (0)