-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple edition setting in capture vs expect_snapshot()
This is appears to be some sort of change in behaviour in withr 2.5.0 vs 3.0.0. The key point is to capture the checklist with testthat 2e in force, while still being able to execute expect_snapshot(), which requires testhat 3e. The changes around the DESCRIPTION file in the test package are separate and are just about making it look more like the DESCRIPTION file of a package who hasn't updated to testthat 3e.
- Loading branch information
Showing
2 changed files
with
15 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,16 +26,26 @@ test_that("upkeep bullets don't change accidentally",{ | |
|
||
expect_snapshot(writeLines(upkeep_checklist())) | ||
|
||
# Add some files to test conditional todos | ||
# Test some conditional TODOs | ||
use_code_of_conduct("[email protected]") | ||
use_testthat() | ||
writeLines("# test environment\n", "cran-comments.md") | ||
local_mocked_bindings(git_default_branch = function() "master") | ||
|
||
expect_snapshot({ | ||
# Look like a package that hasn't switched to testthat 3e yet | ||
use_testthat() | ||
desc::desc_del("Config/testthat/edition") | ||
desc::desc_del("Suggests") | ||
use_package("testthat", "Suggests") | ||
|
||
# previously (withr 2.5.0) we could put local_edition(2L) inside {..} inside | ||
# the expect_snapshot() call | ||
# that is no longer true with withr 3.0.0, but this hacktastic approach works | ||
local({ | ||
local_edition(2L) | ||
writeLines(upkeep_checklist()) | ||
checklist <<- upkeep_checklist() | ||
}) | ||
|
||
expect_snapshot(writeLines(checklist)) | ||
}) | ||
|
||
test_that("get extra upkeep bullets works", { | ||
|