From 9f0d412d9541b7060953d0920ab25bf840321928 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 15 Dec 2022 10:50:29 -0500 Subject: [PATCH] Add test for #376 --- tests/testthat/test-read-xml.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/testthat/test-read-xml.R b/tests/testthat/test-read-xml.R index 60d625eb..4ee42542 100644 --- a/tests/testthat/test-read-xml.R +++ b/tests/testthat/test-read-xml.R @@ -106,3 +106,14 @@ test_that("read_xml and read_html fail with > 1 input", { expect_error(read_xml(c("foo", "bar")), "`x` must be a string of length 1") expect_error(read_html(c("foo", "bar")), "`x` must be a string of length 1") }) + +test_that("read_xml with an invalid file allows deletion of the file (#376)", { + tmp <- tempfile(fileext = ".xml") + on.exit(unlink(tmp)) + writeLines("", con = tmp) + + expect_error( + read_xml(tmp) + ) + expect_true(file.remove(tmp)) +})