diff --git a/tests/testthat/_snaps/py_require.md b/tests/testthat/_snaps/py_require.md index 4157edbf1..086eb3c2e 100644 --- a/tests/testthat/_snaps/py_require.md +++ b/tests/testthat/_snaps/py_require.md @@ -13,12 +13,11 @@ > py_require("numpy<2") > py_require("numpy>=2") > import("numpy") - × No solution found when resolving tool dependencies: - ╰─▶ Because you require numpy<2 and numpy>=2, we can conclude that your - requirements are unsatisfiable. + error: No solution found when resolving tool dependencies + cause: Because you require numpy<2 and numpy>=2, we can conclude that your requirements are unsatisfiable. uv error code: 1 -- Current requirements ------------------------------------------------- - Python: 3.12.xx (reticulate default) + Python: (reticulate default) Packages: numpy, numpy<2, numpy>=2 ------------------------------------------------------------------------- Error in uv_get_or_create_env() : @@ -166,12 +165,11 @@ Output > py_require(c("pandas", "numpy", "notexists")) > uv_get_or_create_env() - × No solution found when resolving tool dependencies: - ╰─▶ Because notexists was not found in the package registry and you require - notexists, we can conclude that your requirements are unsatisfiable. + error: No solution found when resolving tool dependencies + cause: Because notexists was not found in the package registry and you require notexists, we can conclude that your requirements are unsatisfiable. uv error code: 1 -- Current requirements ------------------------------------------------- - Python: 3.12.xx (reticulate default) + Python: (reticulate default) Packages: numpy, pandas, notexists ------------------------------------------------------------------------- Error in uv_get_or_create_env() : @@ -218,7 +216,7 @@ > py_require() ══════════════════════════ Python requirements ══════════════════════════ ── Current requirements ───────────────────────────────────────────────── - Python: [No Python version specified. Will default to '3.12.xx'] + Python: [No Python version specified. Will default to ''] Packages: numpy, pandas, numpy==2 ── Python requirement requests (in order) ─────────────────────────────── 1. R package reticulate: @@ -245,7 +243,7 @@ > py_require() ══════════════════════════ Python requirements ══════════════════════════ ── Current requirements ───────────────────────────────────────────────── - Python: [No Python version specified. Will default to '3.12.xx'] + Python: [No Python version specified. Will default to ''] Packages: numpy, pandas ── Python requirement requests (in order) ─────────────────────────────── 1. R package reticulate: @@ -274,7 +272,7 @@ > py_require() ══════════════════════════ Python requirements ══════════════════════════ ── Current requirements ───────────────────────────────────────────────── - Python: [No Python version specified. Will default to '3.12.xx'] + Python: [No Python version specified. Will default to ''] Packages: numpy, pandas Exclude: Anything newer than 1990-01-01 ── Python requirement requests (in order) ─────────────────────────────── @@ -379,12 +377,11 @@ > library(reticulate) > py_require("os") > os <- import("os") - × No solution found when resolving tool dependencies: - ╰─▶ Because os was not found in the package registry and you require os, we - can conclude that your requirements are unsatisfiable. + error: No solution found when resolving tool dependencies + cause: Because os was not found in the package registry and you require os, we can conclude that your requirements are unsatisfiable. uv error code: 1 -- Current requirements ------------------------------------------------- - Python: 3.12.xx (reticulate default) + Python: (reticulate default) Packages: numpy, os ------------------------------------------------------------------------- Hint: `py_require()` expects Python package names rather than Python module names. diff --git a/tests/testthat/test-py_require.R b/tests/testthat/test-py_require.R index 2e0cb03fd..5f4560fb8 100644 --- a/tests/testthat/test-py_require.R +++ b/tests/testthat/test-py_require.R @@ -1,11 +1,22 @@ -transform_scrub_python_patch <- function(x) { +transform_scrub_python_version <- function(x) { x <- sub("3\\.([0-9]{1,2})\\.[0-9]{1,2}", "3.\\1.xx", x) + # The default Python version moves with each new Python release. + x <- sub( + "3\\.[0-9]{1,2}\\.xx \\(reticulate default\\)", + " (reticulate default)", + x + ) + x <- sub( + "Will default to '3\\.[0-9]{1,2}\\.xx'", + "Will default to ''", + x + ) # uv may report install timing depending on cache state; keep snapshots stable. x <- x[!grepl("^\\s*Installed [0-9]+ package(s)? in [0-9]+ms\\s*$", x)] x } -expect_snapshot2 <- function(..., transform = transform_scrub_python_patch) { +expect_snapshot2 <- function(..., transform = transform_scrub_python_version) { expect_snapshot(..., transform = transform) } @@ -281,7 +292,7 @@ test_that("py_require() warns missing packages in a virtual env", { expect_snapshot2( do.call(r_session, list(force_managed_python = FALSE, exprs = expr)), transform = function(x) { - x <- transform_scrub_python_patch(x) + x <- transform_scrub_python_version(x) # scrub paths gsub("[A-Za-z]:[\\\\/][^\"' ]+|/[A-Za-z0-9._/\\\\-]+", "***", x) }