Skip to content

Commit

Permalink
cleanup testing detritus
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Aug 15, 2023
1 parent 68d85fb commit eb5d21b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
clean_python_tmp_dir <- function() {

if(!reticulate::py_available())
# python never initialized, nothing to do
return()

python_temp_dir <- dirname(reticulate::py_run_string(
"import tempfile; x=tempfile.NamedTemporaryFile().name",
local = TRUE
)$x)

detritus <- list.files(
path = python_temp_dir,
pattern = "__autograph_generated_file|__pycache__",
full.names = TRUE,
all.files = TRUE
)

unlink(detritus, recursive = TRUE)
}

withr::defer(clean_python_tmp_dir(), teardown_env())

0 comments on commit eb5d21b

Please sign in to comment.