From c76756e8dc723dd82423558ffb294257d744e5b8 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Wed, 9 Apr 2025 16:21:43 -0700 Subject: [PATCH] Refactor skip_on_python_older_than to not init --- r/tests/testthat/helper-skip.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/r/tests/testthat/helper-skip.R b/r/tests/testthat/helper-skip.R index ce2ad34e9f4..eb69fb55dc4 100644 --- a/r/tests/testthat/helper-skip.R +++ b/r/tests/testthat/helper-skip.R @@ -116,11 +116,16 @@ skip_on_python_older_than <- function(python_version) { return() } - if (!reticulate::py_available(initialize = TRUE)) { + # We want to be careful not to initialize reticulate in this helper function + config <- reticulate::py_discover_config() + + # It isn't documented, but config should be NULL when py_discovery_config() + # fails to find a valid Python installation + if (is.null(config)) { skip("Python isn't available") } - if (reticulate::py_version() < python_version) { + if (config$version < python_version) { skip(paste("Python version:", reticulate::py_version())) } }