FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix Windows path handling in save_image() by cpsievert · Pull Request #2487 · plotly/plotly.R · GitHub

Repository navigation

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .R  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Next Next commit
test: capture Windows path regression in kaleido
  • Loading branch information
cpsievert committed Apr 13, 2026
commit b669a199f6c0231c04d2218f619029dfbc0a1d23
45 changes: 45 additions & 0 deletions tests/testthat/test-kaleido.R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
test_that("newKaleidoScope does not inline Windows temp paths into Python code", {
skip_if_not_installed("reticulate")
skip_if_not(suppressWarnings(reticulate::py_available(TRUE)))

win_path <- "C:\\users\\name\\AppData\\Local\\Temp\\Rtmp\\file.json"
py_calls <- character()
write_fig_args <- NULL

testthat::local_mocked_bindings(
plotly_build = function(...) {
list(x = list(data = list(), layout = list(), config = list()))
},
to_JSON = function(...) "{}",
plotlyMainBundlePath = function() "plotly.min.js",
.package = "plotly"
)

testthat::local_mocked_bindings(
tempfile = function(...) win_path,
writeLines = function(...) NULL,
Comment thread
cpsievert marked this conversation as resolved.
Resolved
.package = "base"
)

testthat::local_mocked_bindings(
py_run_string = function(code, ...) {
py_calls <<- c(py_calls, code)
py_obj <- get("py", envir = asNamespace("reticulate"))
py_obj$fig <- "fake-fig"
invisible(NULL)
},
.package = "reticulate"
)

kaleido <- list(write_fig_sync = function(fig, file, opts, kopts) {
write_fig_args <<- list(fig = fig, file = file, opts = opts, kopts = kopts)
invisible(NULL)
})

scope <- newKaleidoScope(kaleido)
Comment thread
cpsievert marked this conversation as resolved.
Resolved
scope$transform(list(), "figure.png")

expect_identical(py_calls, "import json; fig = json.load(open(tmp_json_path))")
expect_identical(write_fig_args$fig, "fake-fig")
expect_identical(write_fig_args$file, "figure.png")
})
Comment thread
cpsievert marked this conversation as resolved.
Resolved

Back | FazBrowse Home | New Git URL