Drop-in replacement for testthat::with_mock()
copied from cf-post-staging / r-mockrProvides a means to mock a package function, i.e., temporarily substitute it for testing. Designed as a drop-in replacement for the now deprecated 'testthat::withmock()' and 'testthat::localmock()'.