Open jarad opened 3 months ago
Minimal reprex:
library(testthat)
a <- 1
names(a) <- "a"
expect_equivalent(a, unname(a))
expect_equal(a, unname(a), ignore_attr = TRUE)
#> Error: `a` not equal to unname(a).
#> names for target but not for current
Created on 2024-04-17 with reprex v2.1.0
Hmmm, this is because waldo doesn't consider names to an attribute to be ignored. This needs to be documented better.
In testthat 3.1.10 and waldo 0.5.1, the helpfile for
expect_equivalent()
says that this function is deprecated and suggests you to useexpect_equal(ignore_attr = TRUE)
instead. Unfortunately, these two are apparently not equivalent.In addition, in the helpfile for
waldo::compare()
underignore_attr
, it says "For backward compatibility with all.equal(), you can also use TRUE, to all ignore differences in all attributes. This is not generally recommended as it is a blunt tool that will ignore many important functional differences."The
expect_equivalent()
function was useful and the suggested alternative does not work in the use-case I am interested in.