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
|
context("strings")
test_that("Unicode strings are handled by py_str", {
skip_if_no_python()
skip_on_cran()
skip_on_os("windows")
main <- py_run_string("x = u'\\xfc'", convert = FALSE)
expect_equal(py_str(main$x), "ΓΌ")
})
test_that("subclassed strings convert", {
skip_if_no_python()
skip_on_cran()
# https://github.com/rstudio/reticulate/issues/1348
# https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1015
PrettyString <- py_run_string(
'class PrettyString(str):
def __repr__(self): return self', convert = FALSE)$PrettyString
expect_identical(py_repr(PrettyString("abc_xyz")),
"abc_xyz")
})
|