Skip to content

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?

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

2 participants