Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set option when snapshotting #1798

Merged
merged 2 commits into from
May 31, 2023
Merged

Set option when snapshotting #1798

merged 2 commits into from
May 31, 2023

Conversation

hadley
Copy link
Member

@hadley hadley commented May 26, 2023

Fixes #1796

@hadley hadley requested review from jennybc and kevinushey May 26, 2023 17:46
Comment on lines +470 to +471
withr::local_options(testthat_is_snapshotting = TRUE)
code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't necessarily think this matters but looking at with_ functions I have implemented, I seem to do it like this:

with_is_snapshotting <- function(code) {
  withr::with_options(list(testthat_is_snapshotting = TRUE), code = code)
}

I guess maybe the one difference is whether you force(code) or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the local_ syntax pretty much everywhere.

Copy link
Collaborator

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although I'm curious what the convention is between testthat.option versus testthat_option naming is.

@hadley
Copy link
Member Author

hadley commented May 31, 2023

@kevinushey we're trying to move towards _ everywhere, but there's a lot of places that . remain.

@hadley hadley merged commit 3ac8a78 into main May 31, 2023
@hadley hadley deleted the is_snapshotting branch May 31, 2023 12:14
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.

Set some option in snapshot tests
3 participants