Skip to content

test_that ("danger works") works interactively, but fails under devtools::test() #47

@ambertin

Description

@ambertin

When running the "danger works" test line by line, each line passes successfully. However, when running devtools::test(), the following error occurs:

screen shot 2019-03-04 at 6 59 06 pm

It appears to possibly a problem where we are unable to detach fertile while running test()

Reference code is given below:

danger <- function(expr) {
detach("package:fertile", unload = TRUE)
on.exit(require("fertile"), add = TRUE)
invisible(expr)
}

test_that("danger works", {
wd <- getwd()
expect_error(setwd(tempdir()), "setwd")
expect_message(danger(setwd(path_real(tempdir()))), "fertile")
expect_equal(path_real(getwd()), path_real(tempdir()))
base::setwd(wd)
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions