diff --git a/DESCRIPTION b/DESCRIPTION index bbe806a..0515d78 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,7 +28,8 @@ Suggests: magrittr, mockery, rmarkdown, - testthat (>= 3.0.0) + testthat (>= 3.0.0), + withr VignetteBuilder: knitr Config/Needs/website: tidyverse/tidytemplate diff --git a/tests/testthat/test-xml_parse.R b/tests/testthat/test-xml_parse.R index 2ff6e6c..7e9ef27 100644 --- a/tests/testthat/test-xml_parse.R +++ b/tests/testthat/test-xml_parse.R @@ -110,3 +110,12 @@ test_that("read_xml and read_html fail with > 1 input", { read_html(c("foo", "bar")) }) }) + +test_that("read_xml with an invalid file allows deletion of the file (#376)", { + tmp <- withr::local_tempfile(lines = "") + + n_cons <- nrow(showConnections()) + try(read_xml(tmp), silent = TRUE) + expect_equal(nrow(showConnections()), n_cons) + expect_true(file.remove(tmp)) +})