Skip to content

Commit aa5349b

Browse files
committed
Merged origin/main into plietar-vector-assert
2 parents 68b6f69 + fc2d48d commit aa5349b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6482
-4717
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
^\.git-blame-ignore-rev$
2626
^CLAUDE\.md$
2727
^\.claude$
28+
^vignettes/articles$

CLAUDE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
testthat is R's most popular unit testing framework, used by thousands of CRAN packages. It provides functions to make testing R code as fun and addictive as possible, with clear expectations, visual progress indicators, and seamless integration with R package development workflows.
88

9-
## Key Development Commands
9+
## Key development commands
1010

1111
General advice:
1212
* When running R from the console, always run it with `--quiet --vanilla`
@@ -25,10 +25,11 @@ General advice:
2525

2626
### Documentation
2727

28-
- Always run `devtools::document()` after changing any roxygen2 docs.
28+
- Run `devtools::document()` after changing any roxygen2 docs.
2929
- Every user facing function should be exported and have roxygen2 documentation.
3030
- Whenever you add a new documentation file, make sure to also add the topic name to `_pkgdown.yml`.
3131
- Run `pkgdown::check_pkgdown()` to check that all topics are included in the reference index.
32+
- Use sentence case for all headings
3233

3334
## Core Architecture
3435

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ Config/testthat/parallel: true
5757
Config/testthat/start-first: watcher, parallel*
5858
Encoding: UTF-8
5959
Roxygen: list(markdown = TRUE, r6 = FALSE)
60-
RoxygenNote: 7.3.2
60+
RoxygenNote: 7.3.3

NEWS.md

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

3+
* New `vignette("mocking")` explains mocking in detail (#1265).
4+
* New `vignette("challenging-functions")` provides an index to other documentation organised by testing challenges (#1265).
35
* When running a test interactively, testthat now reports the number of succeses. The results should also be more useful if you are using nested tests.
46
* The hints generated by `expect_snapshot()` and `expect_snapshot_file()` now include the path to the package, if its not in the current working directory (#1577).
5-
* `expect_snapshot_file()` now clearly errors if the `path` doesnt exist (#2191).
7+
* `expect_snapshot_file()` now clearly errors if the `path` doesn't exist (#2191).
68
* `expect_snapshot_file()` now considers `.json` to be a text file (#1593).
79
* `expect_snapshot_file()` now shows differences for text files (#1593).
810
* The failure messages for all `expect_` functions have been rewritten to first state what was expected and then what was actually received (#2142).
@@ -17,7 +19,7 @@
1719
* `local_mock()` and `with_mock()` have been deprecated because they are no longer permitted in R 4.5.
1820
* `snapshot_review()` now passes `...` on to `shiny::runApp()` (#1928).
1921
* `expect_named()` now gives more informative errors (#2091).
20-
* `expect_*()` functions consistently and rigorously check their inputs (#1754).
22+
* `expect_*()` functions consistently and rigorously check their inputs (#1754).
2123
* `test_that()` no longer warns about the absence of `{}` since it no longer seems to be necessary.
2224
* `test_that()`, `describe()`, and `it()` can now be arbitrarily nested. Each component will skip only if it and its subtests don't contain any expectations. The interactive stop reporter has been fixed so it doesn't duplicate failures. (#2063, #2188).
2325
* Test filtering now works with `it()`, and the `desc` argument can take a character vector in order to recursively filter subtests (i.e. `it()` nested inside of `describe()`) (#2118).
@@ -36,7 +38,7 @@
3638
* New `expect_r6_class()` (#2030).
3739
* `expect_*()` functions consistently and rigorously check their inputs (#1754).
3840
* `JunitReporter()` no longer fails with `"no applicable method for xml_add_child"` for warnings outside of tests (#1913). Additionally, warnings now save their backtraces.
39-
* `JunitReporter()` strips ANSI escapes in more placese (#1852, #2032).
41+
* `JunitReporter()` strips ANSI escapes in more places (#1852, #2032).
4042
* `try_again()` is now publicised. The first argument is now the number of retries, not tries (#2050).
4143
* `vignette("custom-expectations)` has been overhauled to make it much clearer how to create high-quality expectations (#2113, #2132, #2072).
4244
* `expect_snapshot()` and friends will now fail when creating a new snapshot on CI. This is usually a signal that you've forgotten to run it locally before committing (#1461).
@@ -985,7 +987,7 @@ This release mostly focusses on an overhaul of how testthat works with condition
985987
* In `expect_equal_to_reference()`, the default value for `update` is
986988
now `FALSE` (@BrodieG, #683).
987989

988-
* `expect_error()` now returns the error object as documentated (#724).
990+
* `expect_error()` now returns the error object as documented (#724).
989991
It also now warns if you're using a classed expectation and you're
990992
not using the `class` argument. This is good practice as it decouples the
991993
error object (which tends to be stable) from its rendering to the user
@@ -1677,7 +1679,7 @@ The reporters system class has been considerably refactored to make existing rep
16771679
* `safe_digest()` uses a better strategy, and returns NA for directories
16781680
(#138, #146).
16791681

1680-
* Random praise is renabled by default (again!) (#164).
1682+
* Random praise is re-enabled by default (again!) (#164).
16811683

16821684
* Teamcity reporter now correctly escapes output messages (#150, @windelinckx).
16831685
It also uses nested suites to include test names.

R/expect-named.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ expect_named <- function(
3535
check_bool(ignore.order)
3636
check_bool(ignore.case)
3737

38-
3938
act <- quasi_label(enquo(object), label)
4039

4140
if (missing(expected)) {

R/expect-self-test.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ capture_success_failure <- function(expr) {
3939
#' Use `show_failure()` in examples to print the failure message without
4040
#' throwing an error.
4141
#'
42-
#' @param expr Code to evalute
42+
#' @param expr Code to evaluate
4343
#' @param message Check that the failure message matches this regexp.
4444
#' @param ... Other arguments passed on to [expect_match()].
4545
#' @export

R/expect-setequal.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ expect_setequal <- function(object, expected) {
2828
act <- quasi_label(enquo(object))
2929
exp <- quasi_label(enquo(expected))
3030

31-
check_vector(object)
32-
check_vector(expected)
31+
check_vector(act$val, error_arg = "object")
32+
check_vector(exp$val, error_arg = "expected")
3333
if (!is.null(names(act$val)) && !is.null(names(exp$val))) {
3434
testthat_warn("expect_setequal() ignores names")
3535
}

R/expect-that.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#' @param srcref Location of the failure. Should only needed to be explicitly
1616
#' supplied when you need to forward a srcref captured elsewhere.
1717
#' @param trace_env If `trace` is not specified, this is used to generate an
18-
#' informative traceack for failures. You should only need to set this if
18+
#' informative traceback for failures. You should only need to set this if
1919
#' you're calling `fail()` from a helper function; see
2020
#' `vignette("custom-expectation")` for details.
2121
#' @param trace An optional backtrace created by [rlang::trace_back()].

R/mock2.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
#'
101101
#' To mock a function that returns different values in sequence,
102102
#' for instance an API call whose status would be 502 then 200,
103-
#' or an user intput to `readline()`, you can use [mock_output_sequence()]
103+
#' or an user input to `readline()`, you can use [mock_output_sequence()]
104104
#'
105105
#' ```R
106106
#' local_mocked_bindings(readline = mock_output_sequence("3", "This is a note", "n"))

R/quasi-label.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ quasi_label <- function(quo, label = NULL, arg = NULL) {
5959
}
6060

6161
labelled_value <- function(value, label) {
62-
list(
63-
val = value,
64-
lab = label
65-
)
62+
if (missing(value)) {
63+
list(val = missing_arg(), lab = label)
64+
} else {
65+
list(val = value, lab = label)
66+
}
6667
}
6768

6869
quasi_capture <- function(.quo, .label, .capture, ...) {

0 commit comments

Comments
 (0)