Skip to content

Commit f81e2b8

Browse files
committed
xml2 and officer are easier to load in in setup
1 parent d74707d commit f81e2b8

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

tests/testthat/setup.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Collection of functions and data pre-processing to help with testing
2+
library(officer)
3+
library(xml2)
24

35
# xml related functions --------------------------------------------------------
46
get_docx_xml <- function(x) {
@@ -10,7 +12,7 @@ get_docx_xml <- function(x) {
1012
x <- docx_file
1113
}
1214
redoc <- read_docx(x)
13-
xml2::xml_child(docx_body_xml(redoc))
15+
xml_child(docx_body_xml(redoc))
1416
}
1517

1618
get_pptx_xml <- function(x) {
@@ -25,7 +27,7 @@ get_pptx_xml <- function(x) {
2527

2628
redoc <- read_pptx(x)
2729
slide <- redoc$slide$get_slide(redoc$cursor)
28-
xml2::xml_child(slide$get())
30+
xml_child(slide$get())
2931
}
3032

3133
get_html_xml <- function(x) {
@@ -35,7 +37,7 @@ get_html_xml <- function(x) {
3537
x <- html_file
3638
}
3739
doc <- read_html(x)
38-
xml2::xml_child(doc, "body")
40+
xml_child(doc, "body")
3941
}
4042
get_pdf_text <- function(x, extract_fun) {
4143
stopifnot(grepl("\\.pdf$", x))

tests/testthat/test-borders.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ test_that("pdf complex borders", {
9292
# skip_if_not_installed("rmarkdown") # in imports surely installed during tests
9393
# skip_if_not(pandoc_available()) # I guess this is in pandoc_version()
9494
# skip_if_not(pandoc_version() > numeric_version("2.7.3"))
95-
rmarkdown::render(rmd_file,
95+
render(rmd_file,
9696
output_format = rmarkdown::pdf_document(latex_engine = "xelatex"),
9797
output_file = pdf_file,
9898
envir = new.env(),

tests/testthat/test-captions-rmd.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ html_file <- gsub("\\.Rmd$", ".html", rmd_file)
1313
docx_file <- gsub("\\.Rmd$", ".docx", rmd_file)
1414
pdf_file <- gsub("\\.Rmd$", ".pdf", rmd_file)
1515

16-
testthat::test_that("with html_document", {
16+
test_that("with html_document", {
1717
skip_if_not_local_testing()
1818
unlink(html_file, force = TRUE)
1919
render(rmd_file,
@@ -110,10 +110,10 @@ test_that("with word_document", {
110110
expect_length(bookmarks, 0)
111111
})
112112

113-
testthat::test_that("with word_document2", {
113+
test_that("with word_document2", {
114114
skip_if_not_local_testing(min_pandoc_version = "2.7.3")
115115
skip_if(pandoc_version() == numeric_version("2.9.2.1"))
116-
testthat::skip_if_not_installed("bookdown")
116+
skip_if_not_installed("bookdown")
117117

118118
unlink(docx_file, force = TRUE)
119119
render(rmd_file,
@@ -149,7 +149,7 @@ testthat::test_that("with word_document2", {
149149

150150

151151

152-
testthat::test_that("word with officer", {
152+
test_that("word with officer", {
153153
unlink(docx_file, force = TRUE)
154154
ft <- flextable(head(cars))
155155
ft <- theme_vanilla(ft)
@@ -193,7 +193,7 @@ test_that("with pdf_document2", {
193193
doc <- get_pdf_text(pdf_file, extract_fun = pdftools::pdf_text)
194194
expect_true(any(grepl("Cross-reference is there: 2", doc, fixed = TRUE)))
195195
} else {
196-
testthat::expect_false(sucess) # only necessary to avoid a note
196+
expect_false(sucess) # only necessary to avoid a note
197197
}
198198
})
199199

0 commit comments

Comments
 (0)