Skip to content

Commit eb5d21b

Browse files
committed
cleanup testing detritus
1 parent 68d85fb commit eb5d21b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/testthat/setup.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
clean_python_tmp_dir <- function() {
2+
3+
if(!reticulate::py_available())
4+
# python never initialized, nothing to do
5+
return()
6+
7+
python_temp_dir <- dirname(reticulate::py_run_string(
8+
"import tempfile; x=tempfile.NamedTemporaryFile().name",
9+
local = TRUE
10+
)$x)
11+
12+
detritus <- list.files(
13+
path = python_temp_dir,
14+
pattern = "__autograph_generated_file|__pycache__",
15+
full.names = TRUE,
16+
all.files = TRUE
17+
)
18+
19+
unlink(detritus, recursive = TRUE)
20+
}
21+
22+
withr::defer(clean_python_tmp_dir(), teardown_env())

0 commit comments

Comments
 (0)