with_mock()
and local_mock()
are superseded in favour of
with_mocked_bindings()
and local_mocked_bindings()
.
These works by using some C code to temporarily modify the mocked function in place. This is abusive of R's internals, which makes it dangerous, and no longer recommended.
with_mock(..., .env = topenv())local_mock(..., .env = topenv(), .local_envir = parent.frame())
The result of the last unnamed parameter
named parameters redefine mocked functions, unnamed parameters will be evaluated after mocking the functions
the environment in which to patch the functions, defaults to the top-level environment. A character is interpreted as package name.
Environment in which to add exit handler. For expert use only.