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

Remove uses of is_testing() #724

Merged
merged 21 commits into from
Mar 14, 2023
Merged

Remove uses of is_testing() #724

merged 21 commits into from
Mar 14, 2023

Conversation

juliasilge
Copy link
Member

Closes #640

@juliasilge
Copy link
Member Author

I am having trouble with the tests similar to r-lib/mockery#57 and it looks like Gabor says that the depth argument doesn't really work. I'm having trouble currently writing a wrapper function that can successfully be stubbed out.

@juliasilge juliasilge marked this pull request as ready for review March 2, 2023 19:11
@juliasilge
Copy link
Member Author

juliasilge commented Mar 2, 2023

The new testthat that has local_mocked_bindings() was just submitted so I think I'll

  • wait until that gets accepted
  • remove all the installation of devel testthat
  • have someone review at that point

@juliasilge
Copy link
Member Author

It's taking a while for the new testthat to get on CRAN so let's do this instead:

  • review now and merge
  • later remove all the installation of devel testthat (before the next release)


old <- readBin(path, "raw", fs::file_size(path))
write_rds_test <- function(x, path) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is only used in one test, but the function is called directly so I can't seem to mock it. If I do this:

local_mocked_bindings(write_rds = write_rds_test)

it does not mock the results when I call write_rds(). Is that right?

@@ -5,7 +5,7 @@ test_that("non-existent file returns default data", {
test_that("standard metadata is useful", {
df <- data.frame(x = 1:10)
path <- withr::local_tempfile()
write_rds(df, path)
write_rds_test(df, path)
Copy link
Member Author

Choose a reason for hiding this comment

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

Here is where I am calling write_rds_test(), that function used only here because I can't seem to mock write_rds() if I call it directly.

@juliasilge juliasilge requested a review from hadley March 9, 2023 18:34
Merge commit 'be3437462467c5fdf1eb70490787b09814382839'

#Conflicts:
#	DESCRIPTION
@juliasilge juliasilge merged commit 0771146 into main Mar 14, 2023
@juliasilge juliasilge deleted the no-more-is-testing branch March 14, 2023 16:41
juliasilge added a commit that referenced this pull request Mar 14, 2023
@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use of is_testing() is a problem for folks who program against pins functions
1 participant