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

trouble using test_path() with expect_equal_to_reference() #448

Closed
jennybc opened this Issue Apr 9, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@jennybc
Copy link
Member

jennybc commented Apr 9, 2016

Seems like this should work. But test_path() doesn't want to make a path that doesn't (yet) exist.

library(testthat)
dir(test_path(), pattern = "\\.rds")
#> character(0)
expect_equal_to_reference(1, "tests/testthat/one.rds")
dir(test_path(), pattern = "\\.rds")
#> [1] "one.rds"
file.remove(test_path("one.rds"))
#> [1] TRUE
dir(test_path(), pattern = "\\.rds")
#> character(0)
expect_equal_to_reference(1, test_path("one.rds"))
#> Error: `tests/testthat/one.rds` doesn't exist
@jennybc

This comment has been minimized.

Copy link
Member Author

jennybc commented Apr 9, 2016

I now see "An error will be thrown if the path doesn't exist." in the help file. OK. But isn't this one of the main uses for test_path()?

@krlmlr

This comment has been minimized.

Copy link
Member

krlmlr commented Apr 16, 2016

I agree that testing if the file exists shouldn't be the responsibility of test_path(). Removing the check and amending the documentation seems fair to me.

@hadley hadley added the bug label Dec 15, 2016

@hadley hadley modified the milestone: 1.1.0 Dec 16, 2016

@hadley hadley closed this in e3cb94f Dec 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.