File: test-python-pipenv.R

package info (click to toggle)
r-cran-reticulate 1.41.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,088 kB
  • sloc: cpp: 5,154; python: 620; sh: 13; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 899 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
context("pipenv")

test_that("reticulate uses the pipenv-configured version of Python", {

  skip_on_cran()
  if (!nzchar(Sys.which("pipenv")))
    skip("pipenv is not installed")

  # use R session directory for tempdir
  withr::local_envvar(TMPDIR = tempdir())

  # move to temporary directory
  project <- tempfile("pipenv-")
  dir.create(project)
  on.exit(unlink(project), add = TRUE)

  owd <- setwd(project)
  on.exit(setwd(owd), add = TRUE)

  # initialize a pipenv project
  system("pipenv install", ignore.stdout = TRUE, ignore.stderr = TRUE)

  # ask for virtualenv path
  expected <- system("pipenv --py", intern = TRUE)

  # try running reticulate in child process
  fmt <- "R --vanilla -s -e '%s'"
  cmd <- sprintf(fmt, "writeLines(reticulate::py_config()$python)")
  actual <- system(cmd, intern = TRUE)

  expect_equal(
    normalizePath(expected),
    normalizePath(actual)
  )

})