Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ License: MIT + file LICENSE
URL: https://testthat.r-lib.org, https://github.com/r-lib/testthat
BugReports: https://github.com/r-lib/testthat/issues
Depends:
R (>= 3.6.0)
R (>= 4.1.0)
Imports:
brio (>= 1.1.3),
callr (>= 3.7.3),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# testthat (development version)

* testthat now requires R 4.1.
* `expect_s4_class()` now supports unquoting (@stibu81, #2064).
* `it()` now finds the correct evaluation environment in more cases (@averissimo, #2085).
* Fixed an issue preventing compilation from succeeding due to deprecation / removal of `std::uncaught_exception()` (@kevinushey, #2047).
Expand Down
2 changes: 1 addition & 1 deletion R/snapshot-cleanup.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ snapshot_expected <- function(
}

dir_contains <- function(paths, expected_files) {
map_lgl(paths, ~ any(file.exists(file.path(.x, expected_files))))
map_lgl(paths, \(path) any(file.exists(file.path(path, expected_files))))
}
1 change: 0 additions & 1 deletion tests/testthat/_snaps/R4.0/snapshot-file/version.txt

This file was deleted.

7 changes: 0 additions & 7 deletions tests/testthat/_snaps/R4.0/snapshot.md

This file was deleted.

2 changes: 1 addition & 1 deletion tests/testthat/test-expect-condition.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ test_that("can capture Throwable conditions from rJava", {

test_that("capture correct trace_env (#1994)", {
# This should fail, not error
expect_failure(expect_error(stop("oops")) %>% expect_warning())
expect_failure(expect_error(stop("oops")) |> expect_warning())
expect_failure(expect_warning(expect_error(stop("oops"))))
})

Expand Down
5 changes: 1 addition & 4 deletions tests/testthat/test-expect-equality.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ test_that("can control numeric tolerance", {
expect_failure(expect_equal(x1, x2))
expect_success(expect_equal(x1, x2, tolerance = 1e-5))
expect_success(expect_equivalent(x1, x2, tolerance = 1e-5))

# with partial matching
# we work around https://github.com/r-lib/testthat/issues/1188
if (getRversion() < "3.6.0" && is.null(getOption("warnPartialMatchArgs"))) {
options(warnPartialMatchArgs = FALSE)
}
withr::local_options(warnPartialMatchArgs = FALSE)
expect_success(expect_equal(x1, x2, tol = 1e-5))

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-expect-no-condition.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ test_that("expect_no_* don't emit success when they fail", {

test_that("capture correct trace_env (#1994)", {
# This should fail, not error
expect_failure(expect_message({message("a"); warn("b")}) %>% expect_no_warning())
expect_failure(expect_no_message({message("a"); warn("b")}) %>% expect_warning())
expect_failure(expect_message({message("a"); warn("b")}) |> expect_no_warning())
expect_failure(expect_no_message({message("a"); warn("b")}) |> expect_warning())
})

test_that("unmatched conditions bubble up", {
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-snapshot-file.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
test_that("expect_snapshot_file works", {
skip_if_not(getRversion() >= "3.6.0")
expect_snapshot_file(
write_tmp_lines(letters),
"foo.r",
Expand Down Expand Up @@ -33,7 +32,6 @@ test_that("expect_snapshot_file works", {


test_that("expect_snapshot_file works in a different directory", {
skip_if_not(getRversion() >= "3.6.0")
path <- withr::local_tempdir()
withr::local_dir(path)

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-snapshot-reporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ test_that("basic workflow", {
snapper <- local_snapshotter(path)
snapper$start_file("snapshot-2")
# output if not active (because test not set here)
expect_snapshot_output("x") %>%
expect_message("Can't save") %>%
expect_snapshot_output("x") |>
expect_message("Can't save") |>
expect_output("[1] \"x\"", fixed = TRUE)

# warns on first creation
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test_that("can scrub output/messages/warnings/errors", {
expect_snapshot(secret(), transform = redact, error = TRUE)

# Or with an inline fun
expect_snapshot(print("secret"), transform = ~ gsub("secret", "****", .x))
expect_snapshot(print("secret"), transform = \(x) gsub("secret", "****", x))
})

test_that("always checks error status", {
Expand Down
6 changes: 3 additions & 3 deletions vignettes/custom-expectation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Next you call `expect()`. This has two arguments:
Expectation functions are called primarily for their side-effects (triggering a failure), so should invisibly return their input, `act$val`. This allows expectations to be chained:

```{r}
mtcars %>%
expect_type("list") %>%
expect_s3_class("data.frame") %>%
mtcars |>
expect_type("list") |>
expect_s3_class("data.frame") |>
expect_length(11)
```

Expand Down
10 changes: 5 additions & 5 deletions vignettes/third-edition.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ expect_warning(f(), "First")
You can either add additional expectations to catch these warnings, or silence them all with `suppressWarnings()`:

```{r}
f() %>%
expect_warning("First") %>%
expect_warning("Second") %>%
f() |>
expect_warning("First") |>
expect_warning("Second") |>
expect_warning("Third")

f() %>%
expect_warning("First") %>%
f() |>
expect_warning("First") |>
suppressWarnings()
```

Expand Down
Loading