Skip to content

Tweak how httr2 mocking function is set#141

Merged
sckott merged 1 commit intoropensci:mainfrom
hadley:httr2-mock-set
Apr 14, 2025
Merged

Tweak how httr2 mocking function is set#141
sckott merged 1 commit intoropensci:mainfrom
hadley:httr2-mock-set

Conversation

@hadley
Copy link
Copy Markdown
Member

@hadley hadley commented Apr 13, 2025

There's no need to use local_ here since you're not setting it locally and this avoids a slightly confusing message from withr:

webmockr::enable()
#> CrulAdapter enabled!
#> HttrAdapter enabled!
#> Httr2Adapter enabled!
#> Setting global deferred event(s).
#> i These will be run:
#>   * Automatically, when the R session ends.
#>   * On demand, if you call `withr::deferred_run()`.
#> i Use `withr::deferred_clear()` to clear them without executing.

(In principle, it would be better if webmockr could restore the previous state prior to its mocking, but it's not a big deal given that there are very few other tools that do web mocking).

Description

Related Issue

Example

There's no need to use `local_` here since you're not setting it locally and this avoids a slightly confusing message from withr:

```R
webmockr::enable()
#> CrulAdapter enabled!
#> HttrAdapter enabled!
#> Httr2Adapter enabled!
#> Setting global deferred event(s).
#> i These will be run:
#>   * Automatically, when the R session ends.
#>   * On demand, if you call `withr::deferred_run()`.
#> i Use `withr::deferred_clear()` to clear them without executing.
```

(In principle, it would be better if webmockr could restore the previous state prior to its mocking, but it's not a big deal given that there are very few other tools that do web mocking).
@sckott sckott added this to the v2.2 milestone Apr 14, 2025
@sckott
Copy link
Copy Markdown
Collaborator

sckott commented Apr 14, 2025

makes sense and i like that message disappearing

@sckott sckott merged commit adb2ebf into ropensci:main Apr 14, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants