-
Notifications
You must be signed in to change notification settings - Fork 341
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviorsnapshot π·
Description
I came across another case where the function does not work:
x <- dplyr::group_by(head(iris, 1), Species)
expect_snapshot_value(x, "deparse")
# Error in integer(0) : could not find function "integer"
Problem could be solved by adding another functions to https://github.com/r-lib/testthat/blob/main/R/snapshot-value.R#L71. But I think it's better to use baseenv() instead of emptyenv():
reparse <- function(x) {
env <- env(baseenv(),
new = methods::new,
getClass = methods::getClass
)
eval(parse(text = x), env)
}
This should help with #1678
Side note: there is repeated definition of reparse: https://github.com/r-lib/testthat/blob/main/R/snapshot-value.R#L92
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviorsnapshot π·