These functions represent a second attempt at bringing mocking to testthat, incorporating what we've learned from the mockr, mockery, and mockthat package.
local_mocked_bindings() work by temporarily
changing variable bindings in the namespace of namespace
Generally, it's only safe to mock packages that you own. If you mock other
packages, we recommend using
skip_on_cran() to avoid CRAN failures if the
These functions do not currently affect registered S3 methods.
local_mocked_bindings(..., .package = NULL, .env = caller_env()) with_mocked_bindings(code, ..., .package = NULL)
Name-value pairs providing functions to mock.
The name of the package where mocked functions should be inserted. Generally, you should not need to supply this as it will be automatically detected when whole package tests are run or when there's one package under active development (i.e. loaded with
Environment that defines effect scope. For expert use only.
Code to execute with specified bindings.