Skip to content

Commit

Permalink
Add test for OrderedDict() conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Mar 13, 2024
1 parent 1e00158 commit 129b6f5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/testthat/test-python-dict.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ test_that("ordered dictionaries with non-string keys can be converted", {

})

test_that("ordered dictionaries can be converted", {
skip_if_no_python()

collections <- import("collections", convert = FALSE)
od <- collections$OrderedDict(list(tuple("a", 1),
tuple("b", 2),
tuple("c", 3)))

result <- py_eval("lambda x: x")(od) # implicit conversion to R
expect_identical(result, list(a = 1, b = 2, c = 3))

})

test_that("py_to_r(dict) converts recursively, #1221", {
skip_if_no_python()
skip_if_no_numpy()
Expand Down

0 comments on commit 129b6f5

Please sign in to comment.